From 15a6a64f92151782f409c0e500e572eaf63f6c76 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 20:05:00 +0100 Subject: [PATCH 01/24] Update dependencies from https://github.com/dotnet/arcade build 20240209.2 (#16709) Microsoft.DotNet.Arcade.Sdk From Version 8.0.0-beta.24081.5 -> To Version 8.0.0-beta.24109.2 Co-authored-by: dotnet-maestro[bot] --- eng/Version.Details.xml | 4 ++-- eng/common/post-build/publish-using-darc.ps1 | 4 ++-- .../templates/job/publish-build-assets.yml | 14 +++++++------- eng/common/templates/post-build/post-build.yml | 16 ++++++++-------- .../templates/variables/pool-providers.yml | 12 ++++++------ global.json | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 20b0a1ac71..bad7d26f0b 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -30,9 +30,9 @@ - + https://github.com/dotnet/arcade - be88b08c41971b52ec11aec05ef31e72185d4a1f + 26e06f1515561b634abf0f9e511f29d1baf56be5 diff --git a/eng/common/post-build/publish-using-darc.ps1 b/eng/common/post-build/publish-using-darc.ps1 index 1e779fec4d..5a3a32ea8d 100644 --- a/eng/common/post-build/publish-using-darc.ps1 +++ b/eng/common/post-build/publish-using-darc.ps1 @@ -12,7 +12,7 @@ param( try { . $PSScriptRoot\post-build-utils.ps1 - $darc = Get-Darc + $darc = Get-Darc $optionalParams = [System.Collections.ArrayList]::new() @@ -46,7 +46,7 @@ try { } Write-Host 'done.' -} +} catch { Write-Host $_ Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "There was an error while trying to publish build '$BuildId' to default channels." diff --git a/eng/common/templates/job/publish-build-assets.yml b/eng/common/templates/job/publish-build-assets.yml index fa5446c093..8ec0151def 100644 --- a/eng/common/templates/job/publish-build-assets.yml +++ b/eng/common/templates/job/publish-build-assets.yml @@ -58,7 +58,7 @@ jobs: demands: Cmd # If it's not devdiv, it's dnceng ${{ if ne(variables['System.TeamProject'], 'DevDiv') }}: - name: $(DncEngInternalBuildPool) + name: NetCore1ESPool-Publishing-Internal demands: ImageOverride -equals windows.vs2019.amd64 steps: @@ -71,7 +71,7 @@ jobs: checkDownloadedFiles: true condition: ${{ parameters.condition }} continueOnError: ${{ parameters.continueOnError }} - + - task: NuGetAuthenticate@1 - task: PowerShell@2 @@ -86,7 +86,7 @@ jobs: /p:OfficialBuildId=$(Build.BuildNumber) condition: ${{ parameters.condition }} continueOnError: ${{ parameters.continueOnError }} - + - task: powershell@2 displayName: Create ReleaseConfigs Artifact inputs: @@ -95,7 +95,7 @@ jobs: Add-Content -Path "$(Build.StagingDirectory)/ReleaseConfigs.txt" -Value $(BARBuildId) Add-Content -Path "$(Build.StagingDirectory)/ReleaseConfigs.txt" -Value "$(DefaultChannels)" Add-Content -Path "$(Build.StagingDirectory)/ReleaseConfigs.txt" -Value $(IsStableBuild) - + - task: PublishBuildArtifacts@1 displayName: Publish ReleaseConfigs Artifact inputs: @@ -121,7 +121,7 @@ jobs: - task: PublishBuildArtifacts@1 displayName: Publish SymbolPublishingExclusionsFile Artifact - condition: eq(variables['SymbolExclusionFile'], 'true') + condition: eq(variables['SymbolExclusionFile'], 'true') inputs: PathtoPublish: '$(Build.SourcesDirectory)/eng/SymbolPublishingExclusionsFile.txt' PublishLocation: Container @@ -137,7 +137,7 @@ jobs: displayName: Publish Using Darc inputs: filePath: $(Build.SourcesDirectory)/eng/common/post-build/publish-using-darc.ps1 - arguments: -BuildId $(BARBuildId) + arguments: -BuildId $(BARBuildId) -PublishingInfraVersion 3 -AzdoToken '$(publishing-dnceng-devdiv-code-r-build-re)' -MaestroToken '$(MaestroApiAccessToken)' @@ -148,4 +148,4 @@ jobs: - ${{ if eq(parameters.enablePublishBuildArtifacts, 'true') }}: - template: /eng/common/templates/steps/publish-logs.yml parameters: - JobLabel: 'Publish_Artifacts_Logs' + JobLabel: 'Publish_Artifacts_Logs' diff --git a/eng/common/templates/post-build/post-build.yml b/eng/common/templates/post-build/post-build.yml index 3f74abf7ce..aba44a25a3 100644 --- a/eng/common/templates/post-build/post-build.yml +++ b/eng/common/templates/post-build/post-build.yml @@ -39,7 +39,7 @@ parameters: displayName: Enable NuGet validation type: boolean default: true - + - name: publishInstallersAndChecksums displayName: Publish installers and checksums type: boolean @@ -131,8 +131,8 @@ stages: displayName: Validate inputs: filePath: $(Build.SourcesDirectory)/eng/common/post-build/nuget-validation.ps1 - arguments: -PackagesPath $(Build.ArtifactStagingDirectory)/PackageArtifacts/ - -ToolDestinationPath $(Agent.BuildDirectory)/Extract/ + arguments: -PackagesPath $(Build.ArtifactStagingDirectory)/PackageArtifacts/ + -ToolDestinationPath $(Agent.BuildDirectory)/Extract/ - job: displayName: Signing Validation @@ -221,9 +221,9 @@ stages: displayName: Validate inputs: filePath: $(Build.SourcesDirectory)/eng/common/post-build/sourcelink-validation.ps1 - arguments: -InputPath $(Build.ArtifactStagingDirectory)/BlobArtifacts/ - -ExtractPath $(Agent.BuildDirectory)/Extract/ - -GHRepoName $(Build.Repository.Name) + arguments: -InputPath $(Build.ArtifactStagingDirectory)/BlobArtifacts/ + -ExtractPath $(Agent.BuildDirectory)/Extract/ + -GHRepoName $(Build.Repository.Name) -GHCommit $(Build.SourceVersion) -SourcelinkCliVersion $(SourceLinkCLIVersion) continueOnError: true @@ -258,7 +258,7 @@ stages: demands: Cmd # If it's not devdiv, it's dnceng ${{ else }}: - name: $(DncEngInternalBuildPool) + name: NetCore1ESPool-Publishing-Internal demands: ImageOverride -equals windows.vs2019.amd64 steps: - template: setup-maestro-vars.yml @@ -272,7 +272,7 @@ stages: displayName: Publish Using Darc inputs: filePath: $(Build.SourcesDirectory)/eng/common/post-build/publish-using-darc.ps1 - arguments: -BuildId $(BARBuildId) + arguments: -BuildId $(BARBuildId) -PublishingInfraVersion ${{ parameters.publishingInfraVersion }} -AzdoToken '$(publishing-dnceng-devdiv-code-r-build-re)' -MaestroToken '$(MaestroApiAccessToken)' diff --git a/eng/common/templates/variables/pool-providers.yml b/eng/common/templates/variables/pool-providers.yml index 9cc5c550d3..d236f9fdbb 100644 --- a/eng/common/templates/variables/pool-providers.yml +++ b/eng/common/templates/variables/pool-providers.yml @@ -1,15 +1,15 @@ -# Select a pool provider based off branch name. Anything with branch name containing 'release' must go into an -Svc pool, +# Select a pool provider based off branch name. Anything with branch name containing 'release' must go into an -Svc pool, # otherwise it should go into the "normal" pools. This separates out the queueing and billing of released branches. -# Motivation: +# Motivation: # Once a given branch of a repository's output has been officially "shipped" once, it is then considered to be COGS # (Cost of goods sold) and should be moved to a servicing pool provider. This allows both separation of queueing # (allowing release builds and main PR builds to not intefere with each other) and billing (required for COGS. -# Additionally, the pool provider name itself may be subject to change when the .NET Core Engineering Services -# team needs to move resources around and create new and potentially differently-named pools. Using this template +# Additionally, the pool provider name itself may be subject to change when the .NET Core Engineering Services +# team needs to move resources around and create new and potentially differently-named pools. Using this template # file from an Arcade-ified repo helps guard against both having to update one's release/* branches and renaming. -# How to use: +# How to use: # This yaml assumes your shipped product branches use the naming convention "release/..." (which many do). # If we find alternate naming conventions in broad usage it can be added to the condition below. # @@ -54,4 +54,4 @@ variables: False, 'NetCore1ESPool-Internal' ) - ] \ No newline at end of file + ] diff --git a/global.json b/global.json index 57b76f8692..cd67cb838e 100644 --- a/global.json +++ b/global.json @@ -17,7 +17,7 @@ "perl": "5.38.0.1" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24081.5", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24109.2", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2" } } From 7c984f096990dcbbb2b73791850f7731a04d79bc Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Thu, 15 Feb 2024 12:53:47 +0000 Subject: [PATCH 02/24] Expose FSharpProjectSnapshot data. (#16716) * Expose FSharpProjectSnapshot data. * Trigger CI --- src/Compiler/Service/FSharpProjectSnapshot.fs | 15 ++++++++++++ ...ervice.SurfaceArea.netstandard20.debug.bsl | 24 +++++++++++++++++++ ...vice.SurfaceArea.netstandard20.release.bsl | 24 +++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/src/Compiler/Service/FSharpProjectSnapshot.fs b/src/Compiler/Service/FSharpProjectSnapshot.fs index cdc7ffe925..a5ae2447db 100644 --- a/src/Compiler/Service/FSharpProjectSnapshot.fs +++ b/src/Compiler/Service/FSharpProjectSnapshot.fs @@ -527,6 +527,21 @@ and [] FSha member _.Label = projectSnapshot.Label member _.Identifier = FSharpProjectIdentifier projectSnapshot.ProjectCore.Identifier + member _.ProjectFileName = projectSnapshot.ProjectFileName + member _.ProjectId = projectSnapshot.ProjectId + member _.SourceFiles = projectSnapshot.SourceFiles + member _.ReferencesOnDisk = projectSnapshot.ReferencesOnDisk + member _.OtherOptions = projectSnapshot.OtherOptions + member _.ReferencedProjects = projectSnapshot.ReferencedProjects + + member _.IsIncompleteTypeCheckEnvironment = + projectSnapshot.IsIncompleteTypeCheckEnvironment + + member _.UseScriptResolutionRules = projectSnapshot.UseScriptResolutionRules + member _.LoadTime = projectSnapshot.LoadTime + member _.UnresolvedReferences = projectSnapshot.UnresolvedReferences + member _.OriginalLoadReferences = projectSnapshot.OriginalLoadReferences + member _.Stamp = projectSnapshot.Stamp static member Create ( 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 da61adbe19..0e4eed09ed 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 @@ -2330,15 +2330,39 @@ FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectIdentifier: System.Str FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectIdentifier: System.String get_projectFileName() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectIdentifier: System.String outputFileName FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectIdentifier: System.String projectFileName +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Boolean IsIncompleteTypeCheckEnvironment +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Boolean UseScriptResolutionRules +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Boolean get_IsIncompleteTypeCheckEnvironment() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Boolean get_UseScriptResolutionRules() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: FSharpProjectIdentifier Identifier 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.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot] SourceFiles +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot] get_SourceFiles() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot] ReferencedProjects +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot] get_ReferencedProjects() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk] ReferencesOnDisk +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk] get_ReferencesOnDisk() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[System.String] OtherOptions +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[System.String] get_OtherOptions() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Text.Range,System.String,System.String]] OriginalLoadReferences +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Text.Range,System.String,System.String]] get_OriginalLoadReferences() 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.DocumentSource) +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet] UnresolvedReferences +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet] get_UnresolvedReferences() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[System.Int64] Stamp +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[System.Int64] get_Stamp() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[System.String] ProjectId +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_ProjectId() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.DateTime LoadTime +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.DateTime get_LoadTime() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String Label +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String ProjectFileName FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String get_Label() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String get_ProjectFileName() 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() 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 da61adbe19..0e4eed09ed 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 @@ -2330,15 +2330,39 @@ FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectIdentifier: System.Str FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectIdentifier: System.String get_projectFileName() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectIdentifier: System.String outputFileName FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectIdentifier: System.String projectFileName +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Boolean IsIncompleteTypeCheckEnvironment +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Boolean UseScriptResolutionRules +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Boolean get_IsIncompleteTypeCheckEnvironment() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Boolean get_UseScriptResolutionRules() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: FSharpProjectIdentifier Identifier 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.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot] SourceFiles +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpFileSnapshot] get_SourceFiles() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot] ReferencedProjects +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpReferencedProjectSnapshot] get_ReferencedProjects() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk] ReferencesOnDisk +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+ReferenceOnDisk] get_ReferencesOnDisk() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[System.String] OtherOptions +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[System.String] get_OtherOptions() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Text.Range,System.String,System.String]] OriginalLoadReferences +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`3[FSharp.Compiler.Text.Range,System.String,System.String]] get_OriginalLoadReferences() 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.DocumentSource) +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet] UnresolvedReferences +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.FSharpUnresolvedReferencesSet] get_UnresolvedReferences() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[System.Int64] Stamp +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[System.Int64] get_Stamp() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[System.String] ProjectId +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_ProjectId() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.DateTime LoadTime +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.DateTime get_LoadTime() FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String Label +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String ProjectFileName FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String get_Label() +FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot: System.String get_ProjectFileName() 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() From 7dd03736147607a8228bb595d4c0a021c04c07ce Mon Sep 17 00:00:00 2001 From: dawe Date: Fri, 16 Feb 2024 10:28:19 +0100 Subject: [PATCH 03/24] remove internal from member UsesTransparentCompiler (#16710) --- src/Compiler/Service/service.fsi | 3 ++- ...FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl | 2 ++ ...harp.Compiler.Service.SurfaceArea.netstandard20.release.bsl | 2 ++ tests/service/ProjectAnalysisTests.fs | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Service/service.fsi b/src/Compiler/Service/service.fsi index e74249cd60..83eb54137e 100644 --- a/src/Compiler/Service/service.fsi +++ b/src/Compiler/Service/service.fsi @@ -60,7 +60,8 @@ type public FSharpChecker = bool -> FSharpChecker - member internal UsesTransparentCompiler: bool + [] + member UsesTransparentCompiler: bool /// /// Parse a source code file, returning information about brace matching in the file. 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 0e4eed09ed..0618fc6afc 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 @@ -2038,6 +2038,8 @@ FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: FSharp.Compiler.Symbols. FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String[] DependencyFiles FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String[] get_DependencyFiles() +FSharp.Compiler.CodeAnalysis.FSharpChecker: Boolean UsesTransparentCompiler +FSharp.Compiler.CodeAnalysis.FSharpChecker: Boolean get_UsesTransparentCompiler() FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Create(Microsoft.FSharp.Core.FSharpOption`1[System.Int32], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.String,System.DateTime],Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[System.Object,System.IntPtr,System.Int32]]]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.DocumentSource], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Instance FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker get_Instance() 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 0e4eed09ed..0618fc6afc 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 @@ -2038,6 +2038,8 @@ FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: FSharp.Compiler.Symbols. FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String ToString() FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String[] DependencyFiles FSharp.Compiler.CodeAnalysis.FSharpCheckProjectResults: System.String[] get_DependencyFiles() +FSharp.Compiler.CodeAnalysis.FSharpChecker: Boolean UsesTransparentCompiler +FSharp.Compiler.CodeAnalysis.FSharpChecker: Boolean get_UsesTransparentCompiler() FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Create(Microsoft.FSharp.Core.FSharpOption`1[System.Int32], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.LegacyReferenceResolver], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpFunc`2[System.Tuple`2[System.String,System.DateTime],Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[System.Object,System.IntPtr,System.Int32]]]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.CodeAnalysis.DocumentSource], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker Instance FSharp.Compiler.CodeAnalysis.FSharpChecker: FSharp.Compiler.CodeAnalysis.FSharpChecker get_Instance() diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 8a643c9a7b..266ec0d900 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -7,6 +7,8 @@ module Tests.Service.ProjectAnalysisTests #endif +#nowarn "57" // Experimental stuff + let runningOnMono = try System.Type.GetType("Mono.Runtime") <> null with e -> false open NUnit.Framework From 9381c7b02436e7b7aa15442d5ac7c4442a7e88c3 Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Fri, 16 Feb 2024 12:48:58 +0000 Subject: [PATCH 04/24] Add InvalidateConfiguration endpoint with FSharpProjectSnapshot. (#16718) * Add InvalidateConfiguration endpoint with FSharpProjectSnapshot. * Update src/Compiler/Service/service.fsi Co-authored-by: Petr Pokorny --------- Co-authored-by: Petr Pokorny --- src/Compiler/Service/BackgroundCompiler.fs | 6 ++++++ src/Compiler/Service/BackgroundCompiler.fsi | 2 ++ src/Compiler/Service/TransparentCompiler.fs | 6 ++++++ src/Compiler/Service/service.fs | 4 ++++ src/Compiler/Service/service.fsi | 7 +++++++ ...rp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl | 1 + ....Compiler.Service.SurfaceArea.netstandard20.release.bsl | 1 + 7 files changed, 27 insertions(+) diff --git a/src/Compiler/Service/BackgroundCompiler.fs b/src/Compiler/Service/BackgroundCompiler.fs index f9f952dde7..54bea5584a 100644 --- a/src/Compiler/Service/BackgroundCompiler.fs +++ b/src/Compiler/Service/BackgroundCompiler.fs @@ -133,6 +133,8 @@ type internal IBackgroundCompiler = abstract member InvalidateConfiguration: options: FSharpProjectOptions * userOpName: string -> unit + abstract InvalidateConfiguration: projectSnapshot: FSharpProjectSnapshot * userOpName: string -> unit + abstract member NotifyFileChanged: fileName: string * options: FSharpProjectOptions * userOpName: string -> NodeCode abstract member NotifyProjectCleaned: options: FSharpProjectOptions * userOpName: string -> Async @@ -1612,6 +1614,10 @@ type internal BackgroundCompiler member _.InvalidateConfiguration(options: FSharpProjectOptions, userOpName: string) : unit = self.InvalidateConfiguration(options, userOpName) + member this.InvalidateConfiguration(projectSnapshot: FSharpProjectSnapshot, userOpName: string) : unit = + let options = projectSnapshot.ToOptions() + self.InvalidateConfiguration(options, userOpName) + member _.NotifyFileChanged(fileName: string, options: FSharpProjectOptions, userOpName: string) : NodeCode = self.NotifyFileChanged(fileName, options, userOpName) diff --git a/src/Compiler/Service/BackgroundCompiler.fsi b/src/Compiler/Service/BackgroundCompiler.fsi index f3bf3c96cc..6d63c3b93e 100644 --- a/src/Compiler/Service/BackgroundCompiler.fsi +++ b/src/Compiler/Service/BackgroundCompiler.fsi @@ -112,6 +112,8 @@ type internal IBackgroundCompiler = abstract InvalidateConfiguration: options: FSharpProjectOptions * userOpName: string -> unit + abstract InvalidateConfiguration: projectSnapshot: FSharpProjectSnapshot * userOpName: string -> unit + abstract NotifyFileChanged: fileName: string * options: FSharpProjectOptions * userOpName: string -> NodeCode abstract NotifyProjectCleaned: options: FSharpProjectOptions * userOpName: string -> Async diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index b117fef1bf..19d383d00b 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -2136,6 +2136,12 @@ type internal TransparentCompiler member this.InvalidateConfiguration(options: FSharpProjectOptions, userOpName: string) : unit = backgroundCompiler.InvalidateConfiguration(options, userOpName) + member this.InvalidateConfiguration(projectSnapshot: FSharpProjectSnapshot, _userOpName: string) : unit = + let (FSharpProjectIdentifier(projectFileName, outputFileName)) = + projectSnapshot.Identifier + + this.Caches.Clear(Set.singleton (ProjectIdentifier(projectFileName, outputFileName))) + member this.NotifyFileChanged(fileName: string, options: FSharpProjectOptions, userOpName: string) : NodeCode = backgroundCompiler.NotifyFileChanged(fileName, options, userOpName) diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index 803755ab13..82b43827e1 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -372,6 +372,10 @@ type FSharpChecker let userOpName = defaultArg userOpName "Unknown" backgroundCompiler.InvalidateConfiguration(options, userOpName) + member _.InvalidateConfiguration(projectSnapshot: FSharpProjectSnapshot, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.InvalidateConfiguration(projectSnapshot, userOpName) + /// Clear the internal cache of the given projects. member _.ClearCache(options: seq, ?userOpName: string) = let userOpName = defaultArg userOpName "Unknown" diff --git a/src/Compiler/Service/service.fsi b/src/Compiler/Service/service.fsi index 83eb54137e..b8e87b805f 100644 --- a/src/Compiler/Service/service.fsi +++ b/src/Compiler/Service/service.fsi @@ -405,6 +405,13 @@ type public FSharpChecker = /// An optional string used for tracing compiler operations associated with this request. member InvalidateConfiguration: options: FSharpProjectOptions * ?userOpName: string -> unit + /// + /// This function is called when the configuration is known to have changed for reasons not encoded in the projectSnapshot. + /// For example, dependent references may have been deleted or created. + /// + [] + member InvalidateConfiguration: projectSnapshot: FSharpProjectSnapshot * ?userOpName: string -> unit + /// Clear the internal cache of the given projects. /// The given project options. /// An optional string used for tracing compiler operations associated with this request. 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 0618fc6afc..e526351eff 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 @@ -2088,6 +2088,7 @@ FSharp.Compiler.CodeAnalysis.FSharpChecker: Void ClearCache(System.Collections.G FSharp.Compiler.CodeAnalysis.FSharpChecker: Void ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() FSharp.Compiler.CodeAnalysis.FSharpChecker: Void InvalidateAll() FSharp.Compiler.CodeAnalysis.FSharpChecker: Void InvalidateConfiguration(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) +FSharp.Compiler.CodeAnalysis.FSharpChecker: Void InvalidateConfiguration(FSharpProjectSnapshot, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Boolean IsBindingALambdaAtPosition(FSharp.Compiler.Text.Position) FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Boolean IsPosContainedInApplication(FSharp.Compiler.Text.Position) FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Boolean IsPositionContainedInACurriedParameter(FSharp.Compiler.Text.Position) 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 0618fc6afc..e526351eff 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 @@ -2088,6 +2088,7 @@ FSharp.Compiler.CodeAnalysis.FSharpChecker: Void ClearCache(System.Collections.G FSharp.Compiler.CodeAnalysis.FSharpChecker: Void ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() FSharp.Compiler.CodeAnalysis.FSharpChecker: Void InvalidateAll() FSharp.Compiler.CodeAnalysis.FSharpChecker: Void InvalidateConfiguration(FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) +FSharp.Compiler.CodeAnalysis.FSharpChecker: Void InvalidateConfiguration(FSharpProjectSnapshot, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Boolean IsBindingALambdaAtPosition(FSharp.Compiler.Text.Position) FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Boolean IsPosContainedInApplication(FSharp.Compiler.Text.Position) FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Boolean IsPositionContainedInACurriedParameter(FSharp.Compiler.Text.Position) From 11e661948e3223248ea405af0c3d0d326c44f8c2 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 14:26:19 +0100 Subject: [PATCH 05/24] [main] Update dependencies from dotnet/arcade (#16713) * Update dependencies from https://github.com/dotnet/arcade build 20240213.2 Microsoft.DotNet.Arcade.Sdk From Version 8.0.0-beta.24109.2 -> To Version 8.0.0-beta.24113.2 * Update dependencies from https://github.com/dotnet/arcade build 20240213.2 Microsoft.DotNet.Arcade.Sdk From Version 8.0.0-beta.24109.2 -> To Version 8.0.0-beta.24113.2 --------- Co-authored-by: dotnet-maestro[bot] Co-authored-by: Kevin Ransom (msft) --- eng/Version.Details.xml | 4 ++-- global.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index bad7d26f0b..5034841e3e 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -30,9 +30,9 @@ - + https://github.com/dotnet/arcade - 26e06f1515561b634abf0f9e511f29d1baf56be5 + da98edc4c3ea539f109ea320672136ceb32591a7 diff --git a/global.json b/global.json index cd67cb838e..1f759399b0 100644 --- a/global.json +++ b/global.json @@ -17,7 +17,7 @@ "perl": "5.38.0.1" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24109.2", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.24113.2", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2" } } From 0f520bce120bb2561f67e467646f4abbdb89d60c Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Fri, 16 Feb 2024 14:50:48 +0100 Subject: [PATCH 06/24] Do not pass non-thread-safe logger to parallel computations in NodeCode.Parallel (#16717) * don't pass non-threadsafe logger to parallel computations * no need to restore in forks --------- Co-authored-by: Petr --- src/Compiler/Facilities/BuildGraph.fs | 35 ++++++++++++------- src/Compiler/Facilities/DiagnosticsLogger.fs | 15 ++++++++ src/Compiler/Facilities/DiagnosticsLogger.fsi | 7 ++++ .../BuildGraphTests.fs | 22 +++++++++--- 4 files changed, 63 insertions(+), 16 deletions(-) diff --git a/src/Compiler/Facilities/BuildGraph.fs b/src/Compiler/Facilities/BuildGraph.fs index 71f4d3da99..b4abe3ad1e 100644 --- a/src/Compiler/Facilities/BuildGraph.fs +++ b/src/Compiler/Facilities/BuildGraph.fs @@ -25,6 +25,8 @@ let wrapThreadStaticInfo computation = DiagnosticsThreadStatics.BuildPhase <- phase } +let unwrapNode (Node(computation)) = computation + type Async<'T> with static member AwaitNodeCode(node: NodeCode<'T>) = @@ -193,19 +195,28 @@ type NodeCode private () = } static member Parallel(computations: NodeCode<'T> seq) = - let diagnosticsLogger = DiagnosticsThreadStatics.DiagnosticsLogger - let phase = DiagnosticsThreadStatics.BuildPhase + node { + let concurrentLogging = new CaptureDiagnosticsConcurrently() + let phase = DiagnosticsThreadStatics.BuildPhase + // Why does it return just IDisposable? + use _ = concurrentLogging - computations - |> Seq.map (fun (Node x) -> - async { - DiagnosticsThreadStatics.DiagnosticsLogger <- diagnosticsLogger - DiagnosticsThreadStatics.BuildPhase <- phase - return! x - }) - |> Async.Parallel - |> wrapThreadStaticInfo - |> Node + let injectLogger i computation = + let logger = concurrentLogging.GetLoggerForTask($"NodeCode.Parallel {i}") + + async { + DiagnosticsThreadStatics.DiagnosticsLogger <- logger + DiagnosticsThreadStatics.BuildPhase <- phase + return! unwrapNode computation + } + + return! + computations + |> Seq.mapi injectLogger + |> Async.Parallel + |> wrapThreadStaticInfo + |> Node + } [] module GraphNode = diff --git a/src/Compiler/Facilities/DiagnosticsLogger.fs b/src/Compiler/Facilities/DiagnosticsLogger.fs index 08a46d1a25..75dfaaef39 100644 --- a/src/Compiler/Facilities/DiagnosticsLogger.fs +++ b/src/Compiler/Facilities/DiagnosticsLogger.fs @@ -13,6 +13,7 @@ open System.Reflection open System.Threading open Internal.Utilities.Library open Internal.Utilities.Library.Extras +open System.Collections.Concurrent /// Represents the style being used to format errors [] @@ -883,3 +884,17 @@ type StackGuard(maxDepth: int, name: string) = static member GetDepthOption(name: string) = GetEnvInteger ("FSHARP_" + name + "StackGuardDepth") StackGuard.DefaultDepth + +type CaptureDiagnosticsConcurrently() = + let target = DiagnosticsThreadStatics.DiagnosticsLogger + let loggers = ResizeArray() + + member _.GetLoggerForTask(name) : DiagnosticsLogger = + let logger = CapturingDiagnosticsLogger(name) + loggers.Add logger + logger + + interface IDisposable with + member _.Dispose() = + for logger in loggers do + logger.CommitDelayedDiagnostics target diff --git a/src/Compiler/Facilities/DiagnosticsLogger.fsi b/src/Compiler/Facilities/DiagnosticsLogger.fsi index e9040da36e..bcbdd197b7 100644 --- a/src/Compiler/Facilities/DiagnosticsLogger.fsi +++ b/src/Compiler/Facilities/DiagnosticsLogger.fsi @@ -463,3 +463,10 @@ type CompilationGlobalsScope = member DiagnosticsLogger: DiagnosticsLogger member BuildPhase: BuildPhase + +type CaptureDiagnosticsConcurrently = + new: unit -> CaptureDiagnosticsConcurrently + + member GetLoggerForTask: string -> DiagnosticsLogger + + interface IDisposable diff --git a/tests/FSharp.Compiler.UnitTests/BuildGraphTests.fs b/tests/FSharp.Compiler.UnitTests/BuildGraphTests.fs index 556a9b5bc4..d07b23a5e9 100644 --- a/tests/FSharp.Compiler.UnitTests/BuildGraphTests.fs +++ b/tests/FSharp.Compiler.UnitTests/BuildGraphTests.fs @@ -235,22 +235,36 @@ module BuildGraphTests = Assert.shouldBeTrue graphNode.HasValue Assert.shouldBe (ValueSome 1) (graphNode.TryPeekValue()) - + type ExampleException(msg) = inherit System.Exception(msg) + [] let internal ``NodeCode preserves DiagnosticsThreadStatics`` () = let random = let rng = Random() fun n -> rng.Next n - let job phase _ = node { + let job phase i = node { do! random 10 |> Async.Sleep |> NodeCode.AwaitAsync Assert.Equal(phase, DiagnosticsThreadStatics.BuildPhase) + DiagnosticsThreadStatics.DiagnosticsLogger.DebugDisplay() + |> Assert.shouldBe $"DiagnosticsLogger(NodeCode.Parallel {i})" + + errorR (ExampleException $"job {i}") } let work (phase: BuildPhase) = node { - use _ = new CompilationGlobalsScope(DiscardErrorsLogger, phase) - let! _ = Seq.init 8 (job phase) |> NodeCode.Parallel + let n = 8 + let logger = CapturingDiagnosticsLogger("test NodeCode") + use _ = new CompilationGlobalsScope(logger, phase) + let! _ = Seq.init n (job phase) |> NodeCode.Parallel + + let diags = logger.Diagnostics |> List.map fst + + diags |> List.map _.Phase |> Set |> Assert.shouldBe (Set.singleton phase) + diags |> List.map _.Exception.Message + |> Assert.shouldBe (List.init n <| sprintf "job %d") + Assert.Equal(phase, DiagnosticsThreadStatics.BuildPhase) } From fd321f3197981276b52b9fd4f16c912e2d5af8f7 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Sat, 17 Feb 2024 08:32:22 +0100 Subject: [PATCH 07/24] Update FSharp.Core.fsx (#16726) --- docs/release-notes/FSharp.Core.fsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/FSharp.Core.fsx b/docs/release-notes/FSharp.Core.fsx index 521ef4f630..20fec5f86e 100644 --- a/docs/release-notes/FSharp.Core.fsx +++ b/docs/release-notes/FSharp.Core.fsx @@ -1,4 +1,4 @@ -(** --- +(** --- category: Release Notes categoryindex: 600 index: 3 @@ -14,7 +14,7 @@ open System.IO open Markdig open Common -let path = Path.Combine(__SOURCE_DIRECTORY__, ".FSharp.Compiler.Service") +let path = Path.Combine(__SOURCE_DIRECTORY__, ".FSharp.Core") let nugetPackage = "FSharp.Core" let availableNuGetVersions = getAvailableNuGetVersions nugetPackage From d59adb22396b7a5e99bb51a74cf61b9731ab8fdb Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Sat, 17 Feb 2024 22:00:10 +0100 Subject: [PATCH 08/24] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 58a61e349e..ee55e75dfa 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ You're invited to contribute to future releases of the F# compiler, core library, and tools. Development of this repository can be done on any OS supported by [.NET](https://dotnet.microsoft.com/). -You will also need the latest .NET 7 SDK installed from [here](https://dotnet.microsoft.com/download/dotnet/7.0). +You will also need .NET SDK installed from [here](https://dotnet.microsoft.com/download/dotnet), exact version can be found in the global.json file in the root of the repository. ## Contributing From 7daac8d351fc2365a4415188a4785e4870b6c41b Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Sat, 17 Feb 2024 22:02:41 +0100 Subject: [PATCH 09/24] Update DEVGUIDE.md --- DEVGUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVGUIDE.md b/DEVGUIDE.md index e5480e39ae..4fbd7cac97 100644 --- a/DEVGUIDE.md +++ b/DEVGUIDE.md @@ -49,7 +49,7 @@ Install the latest released [Visual Studio](https://visualstudio.microsoft.com/v * .NET desktop development (also check F# desktop support, as this will install some legacy templates) * Visual Studio extension development -You will also need the latest .NET 7 SDK installed from [here](https://dotnet.microsoft.com/download/dotnet/7.0). +You will also need .NET SDK installed from [here](https://dotnet.microsoft.com/download/dotnet), exact version can be found in the global.json file in the root of the repository. Building is simple: From 44af7c8141b70e33685fcf58d44145a9d93eb7d7 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Sun, 18 Feb 2024 06:28:55 +0100 Subject: [PATCH 10/24] Update DEVGUIDE.md --- DEVGUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVGUIDE.md b/DEVGUIDE.md index 4fbd7cac97..f8029b4546 100644 --- a/DEVGUIDE.md +++ b/DEVGUIDE.md @@ -76,7 +76,7 @@ If you are just developing the core compiler and library then building ``FSharp. We recommend installing the latest Visual Studio preview and using that if you are on Windows. However, if you prefer not to do that, you will need to install the following: * [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-framework/net472) -* [.NET 7](https://dotnet.microsoft.com/download/dotnet/7.0) +* [.NET SDK](https://dotnet.microsoft.com/download/dotnet) (see exact version in global.json file in the repository root). You'll need to pass an additional flag to the build script: From 352f48a1e6a51d9ee374828bba029d3742bac716 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 19 Feb 2024 13:06:42 +0100 Subject: [PATCH 11/24] Remove benchmarks from FCS solution + fix setting LKG flag + no nulls (#16732) --- Directory.Build.props | 3 +-- FSharp.Compiler.Service.sln | 28 ---------------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index a1b18784e9..ed0556c07f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -24,8 +24,6 @@ - true - true false true true @@ -34,6 +32,7 @@ $(ArtifactsDir)obj/$(MSBuildProjectName)/$(Configuration)/ $(ArtifactsDir)/bin/fslex/$(Configuration)/net8.0/fslex.dll $(ArtifactsDir)/bin/fsyacc/$(Configuration)/net8.0/fsyacc.dll + NO_CHECKNULLS;BUILDING_WITH_LKG;NO_NULLCHECKING_LIB_SUPPORT;$(DefineConstants) diff --git a/FSharp.Compiler.Service.sln b/FSharp.Compiler.Service.sln index 45997f8a6d..957f7300e1 100644 --- a/FSharp.Compiler.Service.sln +++ b/FSharp.Compiler.Service.sln @@ -29,12 +29,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmarks", "Benchmarks", tests\benchmarks\FCSBenchmarks\SmokeTestAllBenchmarks.ps1 = tests\benchmarks\FCSBenchmarks\SmokeTestAllBenchmarks.ps1 EndProjectSection EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "HistoricalBenchmark", "tests\benchmarks\FCSBenchmarks\BenchmarkComparison\HistoricalBenchmark.fsproj", "{35F5F1C5-AE4F-4B5A-8D94-1AF708724FD5}" -EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Benchmarks", "tests\benchmarks\FCSBenchmarks\CompilerServiceBenchmarks\FSharp.Compiler.Benchmarks.fsproj", "{C1950E28-1CB7-4DEC-BB3A-8A0443A17282}" -EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "HistoricalBenchmark.Runner", "tests\benchmarks\FCSBenchmarks\BenchmarkComparison\HistoricalBenchmark.Runner\HistoricalBenchmark.Runner.fsproj", "{07CD957A-3C31-4F75-A735-16CE72E1BD71}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DD4D4A7E-D519-4409-89DA-16DCA3EF80AA}" ProjectSection(SolutionItems) = preProject src\Compiler\FSComp.txt = src\Compiler\FSComp.txt @@ -61,8 +55,6 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Interactive EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.UnitTests", "tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj", "{0C0BDAF4-7D47-4BDA-9992-077F63D6B494}" EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Benchmarks.Common", "tests\benchmarks\FSharp.Benchmarks.Common\FSharp.Benchmarks.Common.fsproj", "{A7ACFD1F-D1B8-483A-A210-200BB6B4BD7E}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -97,18 +89,6 @@ Global {2A182B7D-EDA3-4BF2-84B8-C7553BB7A5A7}.Debug|Any CPU.Build.0 = Debug|Any CPU {2A182B7D-EDA3-4BF2-84B8-C7553BB7A5A7}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A182B7D-EDA3-4BF2-84B8-C7553BB7A5A7}.Release|Any CPU.Build.0 = Release|Any CPU - {35F5F1C5-AE4F-4B5A-8D94-1AF708724FD5}.Debug|Any CPU.ActiveCfg = Release|Any CPU - {35F5F1C5-AE4F-4B5A-8D94-1AF708724FD5}.Debug|Any CPU.Build.0 = Release|Any CPU - {35F5F1C5-AE4F-4B5A-8D94-1AF708724FD5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {35F5F1C5-AE4F-4B5A-8D94-1AF708724FD5}.Release|Any CPU.Build.0 = Release|Any CPU - {C1950E28-1CB7-4DEC-BB3A-8A0443A17282}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C1950E28-1CB7-4DEC-BB3A-8A0443A17282}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C1950E28-1CB7-4DEC-BB3A-8A0443A17282}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C1950E28-1CB7-4DEC-BB3A-8A0443A17282}.Release|Any CPU.Build.0 = Release|Any CPU - {07CD957A-3C31-4F75-A735-16CE72E1BD71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {07CD957A-3C31-4F75-A735-16CE72E1BD71}.Debug|Any CPU.Build.0 = Debug|Any CPU - {07CD957A-3C31-4F75-A735-16CE72E1BD71}.Release|Any CPU.ActiveCfg = Release|Any CPU - {07CD957A-3C31-4F75-A735-16CE72E1BD71}.Release|Any CPU.Build.0 = Release|Any CPU {A6995088-3C1D-42BC-B3DD-72B1EEAB23F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A6995088-3C1D-42BC-B3DD-72B1EEAB23F4}.Debug|Any CPU.Build.0 = Debug|Any CPU {A6995088-3C1D-42BC-B3DD-72B1EEAB23F4}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -145,10 +125,6 @@ Global {0C0BDAF4-7D47-4BDA-9992-077F63D6B494}.Debug|Any CPU.Build.0 = Debug|Any CPU {0C0BDAF4-7D47-4BDA-9992-077F63D6B494}.Release|Any CPU.ActiveCfg = Release|Any CPU {0C0BDAF4-7D47-4BDA-9992-077F63D6B494}.Release|Any CPU.Build.0 = Release|Any CPU - {A7ACFD1F-D1B8-483A-A210-200BB6B4BD7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A7ACFD1F-D1B8-483A-A210-200BB6B4BD7E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A7ACFD1F-D1B8-483A-A210-200BB6B4BD7E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A7ACFD1F-D1B8-483A-A210-200BB6B4BD7E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -157,10 +133,6 @@ Global {BFE6E6F1-1B73-404F-A3A5-30B57E5E0731} = {875D91AC-BA4C-4191-AB11-AE461DB9B8DB} {2EF674B9-8B56-4796-9933-42B2629E52C3} = {875D91AC-BA4C-4191-AB11-AE461DB9B8DB} {38A23D53-E2BF-4B76-907F-49F41D60C88E} = {875D91AC-BA4C-4191-AB11-AE461DB9B8DB} - {35F5F1C5-AE4F-4B5A-8D94-1AF708724FD5} = {AF321816-B4A0-41DD-9A1D-484E8A20C6F6} - {C1950E28-1CB7-4DEC-BB3A-8A0443A17282} = {AF321816-B4A0-41DD-9A1D-484E8A20C6F6} - {07CD957A-3C31-4F75-A735-16CE72E1BD71} = {AF321816-B4A0-41DD-9A1D-484E8A20C6F6} - {A7ACFD1F-D1B8-483A-A210-200BB6B4BD7E} = {AF321816-B4A0-41DD-9A1D-484E8A20C6F6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F9A60F3B-D894-4C8E-BA0F-C51115B25A5A} From 9d36d648f85fa5acc6951b0504d538f24f48345e Mon Sep 17 00:00:00 2001 From: dawe Date: Mon, 19 Feb 2024 13:17:31 +0100 Subject: [PATCH 12/24] Improve benchmark unix support (#16702) * fix configuration case * make path construction x-platform * to be consistent * improve path construction --- .../CompilerServiceBenchmarks/CompilerServiceBenchmarks.fs | 3 ++- tests/benchmarks/SmokeTestBenchmarks.ps1 | 2 +- tests/benchmarks/SmokeTestBenchmarks.sh | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fs b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fs index 2b28cdce00..44a0f9fdaa 100644 --- a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fs +++ b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fs @@ -105,7 +105,8 @@ type CompilerServiceBenchmarks() = | Some _ -> configOpt | None -> let checker = FSharpChecker.Create(projectCacheSize = 200) - let source = FSharpSourceText.From(File.OpenRead("""..\..\..\..\..\..\..\..\..\src\Compiler\Checking\CheckExpressions.fs"""), Encoding.Default, FSharpSourceHashAlgorithm.Sha1, true) + let path = __SOURCE_DIRECTORY__ ++ ".." ++ ".." ++ ".." ++ ".." ++ "src" ++ "Compiler" ++ "Checking" ++ "CheckExpressions.fs" + let source = FSharpSourceText.From(File.OpenRead(path), Encoding.Default, FSharpSourceHashAlgorithm.Sha1, true) let assemblies = AppDomain.CurrentDomain.GetAssemblies() |> Array.map (fun x -> x.Location) diff --git a/tests/benchmarks/SmokeTestBenchmarks.ps1 b/tests/benchmarks/SmokeTestBenchmarks.ps1 index 710d8c3e2b..4d5cda02c7 100644 --- a/tests/benchmarks/SmokeTestBenchmarks.ps1 +++ b/tests/benchmarks/SmokeTestBenchmarks.ps1 @@ -9,7 +9,7 @@ function Run { dotnet run ` --project $path ` - -c release ` + -c Release ` --no-build ` --job Dry ` --allCategories short ` diff --git a/tests/benchmarks/SmokeTestBenchmarks.sh b/tests/benchmarks/SmokeTestBenchmarks.sh index 0da2c8f221..75fcd54ec7 100755 --- a/tests/benchmarks/SmokeTestBenchmarks.sh +++ b/tests/benchmarks/SmokeTestBenchmarks.sh @@ -6,7 +6,7 @@ run() { local path=$1 dotnet run \ --project $path \ - -c release \ + -c Release \ --no-build \ --job Dry \ --allCategories short \ From 096ac344bb2a1642cd12778b30b26cb6c3363d4a Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 00:26:10 -0800 Subject: [PATCH 13/24] Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20240219.1 (#16738) Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 9.0.0-alpha.1.24113.1 -> To Version 9.0.0-alpha.1.24119.1 Co-authored-by: dotnet-maestro[bot] --- eng/Version.Details.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 5034841e3e..19f3a32a34 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,9 +1,9 @@ - + https://github.com/dotnet/source-build-reference-packages - 2f79f97b7a6a0cf2ca3297a8fa526e6f4ea98ce2 + 539af5d8ae183d4fe61e8b2f8f4a8505c8a765a7 From 57098f6bc0d30442729c0f3ac7dc663a2e20cf9d Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Thu, 22 Feb 2024 13:31:29 +0000 Subject: [PATCH 14/24] Prefixed module nameof (#16743) * Consider prefixed module name in nameof expression. * Consider prefixed module name in nameof pattern. * Remove foo * Update release notes * Update src/Compiler/Driver/GraphChecking/FileContentMapping.fs Co-authored-by: dawe --------- Co-authored-by: dawe --- .../.FSharp.Compiler.Service/8.0.300.md | 2 +- .../GraphChecking/FileContentMapping.fs | 41 ++++++++++++++++--- .../TypeChecks/Graph/Scenarios.fs | 31 ++++++++++++++ 3 files changed, 67 insertions(+), 7 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 672209d2ed..af927a7cee 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 @@ * Fix missing warning for recursive calls in list comprehensions. ([PR #16652](https://github.com/dotnet/fsharp/pull/16652)) * 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)) +* `nameof Module` expressions and patterns are processed to link files in `--test:GraphBasedChecking`. ([PR #16550](https://github.com/dotnet/fsharp/pull/16550), [PR #16743](https://github.com/dotnet/fsharp/pull/16743)) * 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)) * Various parenthesization API fixes. ([PR #16578](https://github.com/dotnet/fsharp/pull/16578), [PR #16666](https://github.com/dotnet/fsharp/pull/16666)) * Keep parens for problematic exprs (`if`, `match`, etc.) in `$"{(…):N0}"`, `$"{(…),-3}"`, etc. ([PR #16578](https://github.com/dotnet/fsharp/pull/16578)) diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index 15355de5a3..c19edc6ac5 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -310,8 +310,27 @@ let visitSynTypeConstraint (tc: SynTypeConstraint) : FileContentEntry list = let inline (|NameofIdent|_|) (ident: Ident) = if ident.idText = "nameof" then ValueSome() else ValueNone +/// nameof X.Y.Z can be used in expressions and patterns +[] +type NameofResult = + /// Example: nameof X + /// Where X is a module name + | SingleIdent of potentialModuleName: Ident + /// Example: nameof X.Y.Z + /// Where Z is either a module name or something from inside module or namespace Y. + /// Both options need to be explored. + | LongIdent of longIdent: LongIdent + +let visitNameofResult (nameofResult: NameofResult) : FileContentEntry = + match nameofResult with + | NameofResult.SingleIdent moduleName -> visitIdentAsPotentialModuleName moduleName + | NameofResult.LongIdent longIdent -> + // In this case the last part of the LongIdent could be a module name. + // So we should not cut off the last part. + FileContentEntry.PrefixedIdentifier(longIdentToPath false longIdent) + /// Special case of `nameof Module` type of expression -let (|NameofExpr|_|) (e: SynExpr) = +let (|NameofExpr|_|) (e: SynExpr) : NameofResult option = let rec stripParen (e: SynExpr) = match e with | SynExpr.Paren(expr = expr) -> stripParen expr @@ -320,14 +339,20 @@ let (|NameofExpr|_|) (e: SynExpr) = match e with | SynExpr.App(flag = ExprAtomicFlag.NonAtomic; isInfix = false; funcExpr = SynExpr.Ident NameofIdent; argExpr = moduleNameExpr) -> match stripParen moduleNameExpr with - | SynExpr.Ident moduleNameIdent -> Some moduleNameIdent + | SynExpr.Ident moduleNameIdent -> Some(NameofResult.SingleIdent moduleNameIdent) + | SynExpr.LongIdent(longDotId = longIdent) -> + match longIdent.LongIdent with + | [] -> None + // This is highly unlikely to be produced by the parser + | [ moduleNameIdent ] -> Some(NameofResult.SingleIdent moduleNameIdent) + | lid -> Some(NameofResult.LongIdent(lid)) | _ -> None | _ -> None let visitSynExpr (e: SynExpr) : FileContentEntry list = let rec visit (e: SynExpr) (continuation: FileContentEntry list -> FileContentEntry list) : FileContentEntry list = match e with - | NameofExpr moduleNameIdent -> continuation [ visitIdentAsPotentialModuleName moduleNameIdent ] + | NameofExpr nameofResult -> continuation [ visitNameofResult nameofResult ] | SynExpr.Const _ -> continuation [] | SynExpr.Paren(expr = expr) -> visit expr continuation | SynExpr.Quote(operator = operator; quotedExpr = quotedExpr) -> @@ -551,18 +576,22 @@ let (|NameofPat|_|) (pat: SynPat) = | SynPat.LongIdent(longDotId = SynLongIdent(id = [ NameofIdent ]); typarDecls = None; argPats = SynArgPats.Pats [ moduleNamePat ]) -> match stripPats moduleNamePat with | SynPat.LongIdent( - longDotId = SynLongIdent.SynLongIdent(id = [ moduleNameIdent ]; dotRanges = []; trivia = [ None ]) + longDotId = SynLongIdent.SynLongIdent(id = longIdent) extraId = None typarDecls = None argPats = SynArgPats.Pats [] - accessibility = None) -> Some moduleNameIdent + accessibility = None) -> + match longIdent with + | [] -> None + | [ moduleNameIdent ] -> Some(NameofResult.SingleIdent moduleNameIdent) + | lid -> Some(NameofResult.LongIdent lid) | _ -> None | _ -> None let visitPat (p: SynPat) : FileContentEntry list = let rec visit (p: SynPat) (continuation: FileContentEntry list -> FileContentEntry list) : FileContentEntry list = match p with - | NameofPat moduleNameIdent -> continuation [ visitIdentAsPotentialModuleName moduleNameIdent ] + | NameofPat moduleNameIdent -> continuation [ visitNameofResult moduleNameIdent ] | SynPat.Paren(pat = pat) -> visit pat continuation | SynPat.Typed(pat = pat; targetType = t) -> visit pat (fun nodes -> nodes @ visitSynType t) | SynPat.Const _ -> continuation [] diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs index 80f7caecaf..524556dae0 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs @@ -796,6 +796,8 @@ type Foo = class end sourceFile "Program" """ +module Program + printfn "Hello" """ Set.empty @@ -907,6 +909,35 @@ do module Bar let _ = nameof ((Foo)) +""" + (set [| 0 |]) + ] + scenario + "prefixed module name in nameof expression" + [ + sourceFile "A.fs" "module X.Y.Z" Set.empty + sourceFile + "B.fs" + """ +module B + +open System.ComponentModel + +[] +let v = 2 +""" + (set [| 0 |]) + ] + scenario + "prefixed module name in nameof pattern" + [ + sourceFile "A.fs" "module X.Y.Z" Set.empty + sourceFile + "B.fs" + """ +module B + +do ignore (match "" with | nameof X.Y.Z -> () | _ -> ()) """ (set [| 0 |]) ] From 4c93c631a185abc00ad980048b1ae9e9999981b3 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Thu, 22 Feb 2024 16:05:11 +0100 Subject: [PATCH 15/24] Backport of #16550 to 8.0.202 (#16570) * Merge * Bump version * release notes * Versioning --------- Co-authored-by: Florian Verdonck --- .../.FSharp.Compiler.Service/8.0.202.md | 3 + eng/Versions.props | 2 +- .../GraphChecking/DependencyResolution.fs | 15 ++- .../GraphChecking/FileContentMapping.fs | 46 +++++++- src/Compiler/Driver/GraphChecking/Types.fs | 3 + src/Compiler/Driver/GraphChecking/Types.fsi | 3 + .../TypeChecks/Graph/Scenarios.fs | 110 ++++++++++++++++++ 7 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 docs/release-notes/.FSharp.Compiler.Service/8.0.202.md diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.202.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.202.md new file mode 100644 index 0000000000..a34e8e6442 --- /dev/null +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.202.md @@ -0,0 +1,3 @@ +### Fixed + +* `nameof Module` expressions and patterns are processed to link files in `--test:GraphBasedChecking`. ([PR #16570](https://github.com/dotnet/fsharp/pull/16570)) diff --git a/eng/Versions.props b/eng/Versions.props index 598487cde5..0091f15465 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -16,7 +16,7 @@ 8 0 - 200 + 202 0 diff --git a/src/Compiler/Driver/GraphChecking/DependencyResolution.fs b/src/Compiler/Driver/GraphChecking/DependencyResolution.fs index 9300385b48..11ba984ca5 100644 --- a/src/Compiler/Driver/GraphChecking/DependencyResolution.fs +++ b/src/Compiler/Driver/GraphChecking/DependencyResolution.fs @@ -1,7 +1,6 @@ module internal FSharp.Compiler.GraphChecking.DependencyResolution open FSharp.Compiler.Syntax -open Internal.Utilities.Library /// Find a path from a starting TrieNode and return the end node or None let queryTriePartial (trie: TrieNode) (path: LongIdentifier) : TrieNode option = @@ -118,6 +117,20 @@ let rec processStateEntry (trie: TrieNode) (state: FileContentQueryState) (entry FoundDependencies = foundDependencies } + | ModuleName name -> + // We need to check if the module name is a hit in the Trie. + let state' = + let queryResult = queryTrie trie [ name ] + processIdentifier queryResult state + + match state.OwnNamespace with + | None -> state' + | Some ns -> + // If there we currently have our own namespace, + // the combination of that namespace + module name should be checked as well. + let queryResult = queryTrieDual trie ns [ name ] + processIdentifier queryResult state' + /// /// For a given file's content, collect all missing ("ghost") file dependencies that the core resolution algorithm didn't return, /// but are required to satisfy the type-checker. diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index bfdaf4beea..f86298308a 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -18,6 +18,11 @@ let longIdentToPath (skipLast: bool) (longId: LongIdent) : LongIdentifier = let synLongIdentToPath (skipLast: bool) (synLongIdent: SynLongIdent) = longIdentToPath skipLast synLongIdent.LongIdent +/// In some rare cases we are interested in the name of a single Ident. +/// For example `nameof ModuleName` in expressions or patterns. +let visitIdentAsPotentialModuleName (moduleNameIdent: Ident) = + FileContentEntry.ModuleName moduleNameIdent.idText + let visitSynLongIdent (lid: SynLongIdent) : FileContentEntry list = visitLongIdent lid.LongIdent let visitLongIdent (lid: LongIdent) = @@ -302,9 +307,28 @@ let visitSynTypeConstraint (tc: SynTypeConstraint) : FileContentEntry list = | SynTypeConstraint.WhereTyparIsEnum(typeArgs = typeArgs) -> List.collect visitSynType typeArgs | SynTypeConstraint.WhereTyparIsDelegate(typeArgs = typeArgs) -> List.collect visitSynType typeArgs +[] +let inline (|NameofIdent|_|) (ident: Ident) = + if ident.idText = "nameof" then ValueSome() else ValueNone + +/// Special case of `nameof Module` type of expression +let (|NameofExpr|_|) (e: SynExpr) = + let rec stripParen (e: SynExpr) = + match e with + | SynExpr.Paren(expr = expr) -> stripParen expr + | _ -> e + + match e with + | SynExpr.App(flag = ExprAtomicFlag.NonAtomic; isInfix = false; funcExpr = SynExpr.Ident NameofIdent; argExpr = moduleNameExpr) -> + match stripParen moduleNameExpr with + | SynExpr.Ident moduleNameIdent -> Some moduleNameIdent + | _ -> None + | _ -> None + let visitSynExpr (e: SynExpr) : FileContentEntry list = let rec visit (e: SynExpr) (continuation: FileContentEntry list -> FileContentEntry list) : FileContentEntry list = match e with + | NameofExpr moduleNameIdent -> continuation [ visitIdentAsPotentialModuleName moduleNameIdent ] | SynExpr.Const _ -> continuation [] | SynExpr.Paren(expr = expr) -> visit expr continuation | SynExpr.Quote(operator = operator; quotedExpr = quotedExpr) -> @@ -389,7 +413,7 @@ let visitSynExpr (e: SynExpr) : FileContentEntry list = | SynExpr.IfThenElse(ifExpr = ifExpr; thenExpr = thenExpr; elseExpr = elseExpr) -> let continuations = List.map visit (ifExpr :: thenExpr :: Option.toList elseExpr) Continuation.concatenate continuations continuation - | SynExpr.Typar _ -> continuation [] + | SynExpr.Typar _ | SynExpr.Ident _ -> continuation [] | SynExpr.LongIdent(longDotId = longDotId) -> continuation (visitSynLongIdent longDotId) | SynExpr.LongIdentSet(longDotId, expr, _) -> visit expr (fun nodes -> visitSynLongIdent longDotId @ nodes |> continuation) @@ -517,9 +541,29 @@ let visitSynExpr (e: SynExpr) : FileContentEntry list = visit e id +/// Special case of `| nameof Module ->` type of pattern +let (|NameofPat|_|) (pat: SynPat) = + let rec stripPats p = + match p with + | SynPat.Paren(pat = pat) -> stripPats pat + | _ -> p + + match pat with + | SynPat.LongIdent(longDotId = SynLongIdent(id = [ NameofIdent ]); typarDecls = None; argPats = SynArgPats.Pats [ moduleNamePat ]) -> + match stripPats moduleNamePat with + | SynPat.LongIdent( + longDotId = SynLongIdent.SynLongIdent(id = [ moduleNameIdent ]; dotRanges = []; trivia = [ None ]) + extraId = None + typarDecls = None + argPats = SynArgPats.Pats [] + accessibility = None) -> Some moduleNameIdent + | _ -> None + | _ -> None + let visitPat (p: SynPat) : FileContentEntry list = let rec visit (p: SynPat) (continuation: FileContentEntry list -> FileContentEntry list) : FileContentEntry list = match p with + | NameofPat moduleNameIdent -> continuation [ visitIdentAsPotentialModuleName moduleNameIdent ] | SynPat.Paren(pat = pat) -> visit pat continuation | SynPat.Typed(pat = pat; targetType = t) -> visit pat (fun nodes -> nodes @ visitSynType t) | SynPat.Const _ -> continuation [] diff --git a/src/Compiler/Driver/GraphChecking/Types.fs b/src/Compiler/Driver/GraphChecking/Types.fs index 00538b6e59..c667a573f6 100644 --- a/src/Compiler/Driver/GraphChecking/Types.fs +++ b/src/Compiler/Driver/GraphChecking/Types.fs @@ -73,6 +73,9 @@ type internal FileContentEntry = /// Being explicit about nested modules allows for easier reasoning what namespaces (paths) are open. /// We can scope an `OpenStatement` to the everything that is happening inside the nested module. | NestedModule of name: string * nestedContent: FileContentEntry list + /// A single identifier that could be the name of a module. + /// Example use-case: `let x = nameof Foo` where `Foo` is a module. + | ModuleName of name: Identifier type internal FileContent = { diff --git a/src/Compiler/Driver/GraphChecking/Types.fsi b/src/Compiler/Driver/GraphChecking/Types.fsi index 468ef65889..096719b6be 100644 --- a/src/Compiler/Driver/GraphChecking/Types.fsi +++ b/src/Compiler/Driver/GraphChecking/Types.fsi @@ -67,6 +67,9 @@ type internal FileContentEntry = /// Being explicit about nested modules allows for easier reasoning what namespaces (paths) are open. /// For example we can limit the scope of an `OpenStatement` to symbols defined inside the nested module. | NestedModule of name: string * nestedContent: FileContentEntry list + /// A single identifier that could be the name of a module. + /// Example use-case: `let x = nameof Foo` where `Foo` is a module. + | ModuleName of name: Identifier /// File identifiers and its content extract for dependency resolution type internal FileContent = diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs index c75aed594c..80f7caecaf 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs @@ -800,4 +800,114 @@ printfn "Hello" """ Set.empty ] + scenario + "Nameof module with namespace" + [ + sourceFile + "A.fs" + """ +namespace X.Y.Z + +module Foo = + let x = 2 +""" + Set.empty + sourceFile + "B.fs" + """ +namespace X.Y.Z + +module Point = + let y = nameof Foo +""" + (set [| 0 |]) + ] + scenario + "Nameof module without namespace" + [ + sourceFile + "A.fs" + """ +module Foo + +let x = 2 +""" + Set.empty + sourceFile + "B.fs" + """ +module Point + +let y = nameof Foo +""" + (set [| 0 |]) + ] + scenario + "Single module name should always be checked, regardless of own namespace" + [ + sourceFile "X.fs" "namespace X.Y" Set.empty + sourceFile + "A.fs" + """ +module Foo + +let x = 2 +""" + Set.empty + sourceFile + "B.fs" + """ +namespace X.Y + +type T() = + let _ = nameof Foo +""" + (set [| 1 |]) + ] + scenario + "nameof pattern" + [ + sourceFile "A.fs" "module Foo" Set.empty + sourceFile + "B.fs" + """ +module Bar + +do + match "" with + | nameof Foo -> () + | _ -> () +""" + (set [| 0 |]) + ] + scenario + "parentheses around module name in nameof pattern" + [ + sourceFile "A.fs" "module Foo" Set.empty + sourceFile + "B.fs" + """ +module Bar + +do + match "" with + | nameof ((Foo)) -> () + | _ -> () +""" + (set [| 0 |]) + ] + + scenario + "parentheses around module name in nameof expression" + [ + sourceFile "A.fs" "module Foo" Set.empty + sourceFile + "B.fs" + """ +module Bar + +let _ = nameof ((Foo)) +""" + (set [| 0 |]) + ] ] \ No newline at end of file From 2de1f6892fc8b3fe4c75028b6bcd3194278c602d Mon Sep 17 00:00:00 2001 From: Adam Boniecki <20281641+abonie@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:49:21 +0100 Subject: [PATCH 16/24] Lower interpolation into a call to concat (#16556) * Add unit tests for interp strings with string expr Sanity check that lowering to concat does not break these simple cases * Add IL test for lowering to concat * Add optimization in CheckExpressions Initial attempt with many TODOs, also not sure whether it should be done in checking, but it seems that later we would have to again parse the string (since CheckExpressions is going from AST version of an interpolated string to a sprintf call basically) * Do not optimize when format specifiers are there Cannot really optimize this way if width and other flags are specified. Typed interpolated expressions should be possible to support, but skipping them for now (TODO). * Adjust expected length of codegen * Filter out empty string parts E.g. $"{x}{y}" has 5 string parts, including 3 empty strings * Detect format specifiers better There were false positives before * Refactor, improve regex * Unrelated indentation fix in parser * Use language feature flag * FSComp.txt auto-update * Add release notes * Add langversion flag to some unit tests * Fix typo in src/Compiler/FSComp.txt Co-authored-by: Petr * Update .xlf and undo change to CheckFormatStrings * Add a test, undo change in CheckFormatString * Refactor based on review suggestions * Add more IL tests * Add comments lost in refactoring * Automated command ran: fantomas Co-authored-by: psfinaki <5451366+psfinaki@users.noreply.github.com> --------- Co-authored-by: Adam Boniecki Co-authored-by: Petr Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../.FSharp.Compiler.Service/8.0.300.md | 1 + docs/release-notes/.Language/preview.md | 4 + src/Compiler/Checking/CheckExpressions.fs | 113 +++++++++++++++--- src/Compiler/FSComp.txt | 1 + src/Compiler/Facilities/LanguageFeatures.fs | 3 + src/Compiler/Facilities/LanguageFeatures.fsi | 1 + src/Compiler/Utilities/ReadOnlySpan.fs | 12 ++ src/Compiler/Utilities/ReadOnlySpan.fsi | 3 + src/Compiler/pars.fsy | 4 +- src/Compiler/xlf/FSComp.txt.cs.xlf | 5 + src/Compiler/xlf/FSComp.txt.de.xlf | 5 + src/Compiler/xlf/FSComp.txt.es.xlf | 5 + src/Compiler/xlf/FSComp.txt.fr.xlf | 5 + src/Compiler/xlf/FSComp.txt.it.xlf | 5 + src/Compiler/xlf/FSComp.txt.ja.xlf | 5 + src/Compiler/xlf/FSComp.txt.ko.xlf | 5 + src/Compiler/xlf/FSComp.txt.pl.xlf | 5 + src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 + src/Compiler/xlf/FSComp.txt.ru.xlf | 5 + src/Compiler/xlf/FSComp.txt.tr.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 + tests/AheadOfTime/Trimming/check.ps1 | 2 +- .../EmittedIL/StringFormatAndInterpolation.fs | 60 +++++++++- .../Language/InterpolatedStringsTests.fs | 47 +++++++- 25 files changed, 295 insertions(+), 21 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 af927a7cee..80d327e5d9 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -29,3 +29,4 @@ * Reduce allocations in compiler checking via `ValueOption` usage ([PR #16323](https://github.com/dotnet/fsharp/pull/16323), [PR #16567](https://github.com/dotnet/fsharp/pull/16567)) * Reverted [#16348](https://github.com/dotnet/fsharp/pull/16348) `ThreadStatic` `CancellationToken` changes to improve test stability and prevent potential unwanted cancellations. ([PR #16536](https://github.com/dotnet/fsharp/pull/16536)) * Refactored parenthesization API. ([PR #16461])(https://github.com/dotnet/fsharp/pull/16461)) +* Optimize some interpolated strings by lowering to string concatenation. ([PR #16556](https://github.com/dotnet/fsharp/pull/16556)) diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index 832dd924a4..d1880b4dd8 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -8,3 +8,7 @@ ### Fixed * Allow extension methods without type attribute work for types from imported assemblies. ([PR #16368](https://github.com/dotnet/fsharp/pull/16368)) + +### Changed + +* Lower interpolated strings to string concatenation. ([PR #16556](https://github.com/dotnet/fsharp/pull/16556)) \ No newline at end of file diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index e59fb6bd5f..89268e1ee6 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -6,6 +6,7 @@ module internal FSharp.Compiler.CheckExpressions open System open System.Collections.Generic +open System.Text.RegularExpressions open Internal.Utilities.Collections open Internal.Utilities.Library @@ -140,6 +141,43 @@ exception StandardOperatorRedefinitionWarning of string * range exception InvalidInternalsVisibleToAssemblyName of badName: string * fileName: string option +//---------------------------------------------------------------------------------------------- +// Helpers for determining if/what specifiers a string has. +// Used to decide if interpolated string can be lowered to a concat call. +// We don't care about single- vs multi-$ strings here, because lexer took care of that already. +//---------------------------------------------------------------------------------------------- +[] +let (|HasFormatSpecifier|_|) (s: string) = + if + Regex.IsMatch( + s, + // Regex pattern for something like: %[flags][width][.precision][type] + """ + (^|[^%]) # Start with beginning of string or any char other than '%' + (%%)*% # followed by an odd number of '%' chars + [+-0 ]{0,3} # optionally followed by flags + (\d+)? # optionally followed by width + (\.\d+)? # optionally followed by .precision + [bscdiuxXoBeEfFgGMOAat] # and then a char that determines specifier's type + """, + RegexOptions.Compiled ||| RegexOptions.IgnorePatternWhitespace) + then + ValueSome HasFormatSpecifier + else + ValueNone + +// Removes trailing "%s" unless it was escaped by another '%' (checks for odd sequence of '%' before final "%s") +let (|WithTrailingStringSpecifierRemoved|) (s: string) = + if s.EndsWith "%s" then + let i = s.AsSpan(0, s.Length - 2).LastIndexOfAnyExcept '%' + let diff = s.Length - 2 - i + if diff &&& 1 <> 0 then + s[..i] + else + s + else + s + /// Compute the available access rights from a particular location in code let ComputeAccessRights eAccessPath eInternalsVisibleCompPaths eFamilyType = AccessibleFrom (eAccessPath :: eInternalsVisibleCompPaths, eFamilyType) @@ -7336,25 +7374,68 @@ and TcInterpolatedStringExpr cenv (overallTy: OverallTy) env m tpenv (parts: Syn // Type check the expressions filling the holes let fillExprs, tpenv = TcExprsNoFlexes cenv env m tpenv argTys synFillExprs - let fillExprsBoxed = (argTys, fillExprs) ||> List.map2 (mkCallBox g m) + // Take all interpolated string parts and typed fill expressions + // and convert them to typed expressions that can be used as args to System.String.Concat + // return an empty list if there are some format specifiers that make lowering to not applicable + let rec concatenable acc fillExprs parts = + match fillExprs, parts with + | [], [] -> + List.rev acc + | [], SynInterpolatedStringPart.FillExpr _ :: _ + | _, [] -> + // This should never happen, there will always be as many typed fill expressions + // as there are FillExprs in the interpolated string parts + error(InternalError("Mismatch in interpolation expression count", m)) + | _, SynInterpolatedStringPart.String (WithTrailingStringSpecifierRemoved "", _) :: parts -> + // If the string is empty (after trimming %s of the end), we skip it + concatenable acc fillExprs parts + + | _, SynInterpolatedStringPart.String (WithTrailingStringSpecifierRemoved HasFormatSpecifier, _) :: _ + | _, SynInterpolatedStringPart.FillExpr (_, Some _) :: _ + | _, SynInterpolatedStringPart.FillExpr (SynExpr.Tuple (isStruct = false; exprs = [_; SynExpr.Const (SynConst.Int32 _, _)]), _) :: _ -> + // There was a format specifier like %20s{..} or {..,20} or {x:hh}, which means we cannot simply concat + [] - let argsExpr = mkArray (g.obj_ty, fillExprsBoxed, m) - let percentATysExpr = - if percentATys.Length = 0 then - mkNull m (mkArrayType g g.system_Type_ty) - else - let tyExprs = percentATys |> Array.map (mkCallTypeOf g m) |> Array.toList - mkArray (g.system_Type_ty, tyExprs, m) + | _, SynInterpolatedStringPart.String (s & WithTrailingStringSpecifierRemoved trimmed, m) :: parts -> + let finalStr = trimmed.Replace("%%", "%") + concatenable (mkString g (shiftEnd 0 (finalStr.Length - s.Length) m) finalStr :: acc) fillExprs parts - let fmtExpr = MakeMethInfoCall cenv.amap m newFormatMethod [] [mkString g m printfFormatString; argsExpr; percentATysExpr] None + | fillExpr :: fillExprs, SynInterpolatedStringPart.FillExpr _ :: parts -> + concatenable (fillExpr :: acc) fillExprs parts - if isString then - TcPropagatingExprLeafThenConvert cenv overallTy g.string_ty env (* true *) m (fun () -> - // Make the call to sprintf - mkCall_sprintf g m printerTy fmtExpr [], tpenv - ) - else - fmtExpr, tpenv + let canLower = + g.langVersion.SupportsFeature LanguageFeature.LowerInterpolatedStringToConcat + && isString + && argTys |> List.forall (isStringTy g) + + let concatenableExprs = if canLower then concatenable [] fillExprs parts else [] + + match concatenableExprs with + | [p1; p2; p3; p4] -> mkStaticCall_String_Concat4 g m p1 p2 p3 p4, tpenv + | [p1; p2; p3] -> mkStaticCall_String_Concat3 g m p1 p2 p3, tpenv + | [p1; p2] -> mkStaticCall_String_Concat2 g m p1 p2, tpenv + | [p1] -> p1, tpenv + | _ -> + + let fillExprsBoxed = (argTys, fillExprs) ||> List.map2 (mkCallBox g m) + + let argsExpr = mkArray (g.obj_ty, fillExprsBoxed, m) + let percentATysExpr = + if percentATys.Length = 0 then + mkNull m (mkArrayType g g.system_Type_ty) + else + let tyExprs = percentATys |> Array.map (mkCallTypeOf g m) |> Array.toList + mkArray (g.system_Type_ty, tyExprs, m) + + let fmtExpr = MakeMethInfoCall cenv.amap m newFormatMethod [] [mkString g m printfFormatString; argsExpr; percentATysExpr] None + + if isString then + TcPropagatingExprLeafThenConvert cenv overallTy g.string_ty env (* true *) m (fun () -> + // Make the call to sprintf + mkCall_sprintf g m printerTy fmtExpr [], tpenv + ) + else + fmtExpr, tpenv // The case for $"..." used as type FormattableString or IFormattable | Choice2Of2 createFormattableStringMethod -> diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index a9fc269215..1fef46084d 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1594,6 +1594,7 @@ featureWarningIndexedPropertiesGetSetSameType,"Indexed properties getter and set featureChkTailCallAttrOnNonRec,"Raises warnings if the 'TailCall' attribute is used on non-recursive functions." featureUnionIsPropertiesVisible,"Union case test properties" featureBooleanReturningAndReturnTypeDirectedPartialActivePattern,"Boolean-returning and return-type-directed partial active patterns" +featureLowerInterpolatedStringToConcat,"Optimizes interpolated strings in certain cases, by lowering to concatenation" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3355,tcNotAnIndexerNamedIndexingNotYetEnabled,"The value '%s' is not a function and does not support index notation." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index e7c2a25ee3..66547a12e2 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -85,6 +85,7 @@ type LanguageFeature = | WarningIndexedPropertiesGetSetSameType | WarningWhenTailCallAttrOnNonRec | BooleanReturningAndReturnTypeDirectedPartialActivePattern + | LowerInterpolatedStringToConcat /// LanguageVersion management type LanguageVersion(versionText) = @@ -197,6 +198,7 @@ type LanguageVersion(versionText) = LanguageFeature.WarningWhenTailCallAttrOnNonRec, previewVersion LanguageFeature.UnionIsPropertiesVisible, previewVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern, previewVersion + LanguageFeature.LowerInterpolatedStringToConcat, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -340,6 +342,7 @@ type LanguageVersion(versionText) = | LanguageFeature.WarningWhenTailCallAttrOnNonRec -> FSComp.SR.featureChkTailCallAttrOnNonRec () | LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern -> FSComp.SR.featureBooleanReturningAndReturnTypeDirectedPartialActivePattern () + | LanguageFeature.LowerInterpolatedStringToConcat -> FSComp.SR.featureLowerInterpolatedStringToConcat () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 29d6c2c33a..582c191ac8 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -76,6 +76,7 @@ type LanguageFeature = | WarningIndexedPropertiesGetSetSameType | WarningWhenTailCallAttrOnNonRec | BooleanReturningAndReturnTypeDirectedPartialActivePattern + | LowerInterpolatedStringToConcat /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/Utilities/ReadOnlySpan.fs b/src/Compiler/Utilities/ReadOnlySpan.fs index 05683eadb9..a01439bee6 100644 --- a/src/Compiler/Utilities/ReadOnlySpan.fs +++ b/src/Compiler/Utilities/ReadOnlySpan.fs @@ -59,4 +59,16 @@ type ReadOnlySpanExtensions = i <- i - 1 if found then i else -1 + + [] + static member LastIndexOfAnyExcept(span: ReadOnlySpan, value: char) = + let mutable i = span.Length - 1 + let mutable found = false + + while not found && i >= 0 do + let c = span[i] + + if c <> value then found <- true else i <- i - 1 + + if found then i else -1 #endif diff --git a/src/Compiler/Utilities/ReadOnlySpan.fsi b/src/Compiler/Utilities/ReadOnlySpan.fsi index 67591a03f8..b772ab5864 100644 --- a/src/Compiler/Utilities/ReadOnlySpan.fsi +++ b/src/Compiler/Utilities/ReadOnlySpan.fsi @@ -17,4 +17,7 @@ type internal ReadOnlySpanExtensions = [] static member LastIndexOfAnyInRange: span: ReadOnlySpan * lowInclusive: char * highInclusive: char -> int + + [] + static member LastIndexOfAnyExcept: span: ReadOnlySpan * value: char -> int #endif diff --git a/src/Compiler/pars.fsy b/src/Compiler/pars.fsy index 6c5415667d..4080fc7ec8 100644 --- a/src/Compiler/pars.fsy +++ b/src/Compiler/pars.fsy @@ -6776,8 +6776,8 @@ interpolatedStringParts: | INTERP_STRING_END { [ SynInterpolatedStringPart.String(fst $1, rhs parseState 1) ] } - | INTERP_STRING_PART interpolatedStringFill interpolatedStringParts - { SynInterpolatedStringPart.String(fst $1, rhs parseState 1) :: SynInterpolatedStringPart.FillExpr $2 :: $3 } + | INTERP_STRING_PART interpolatedStringFill interpolatedStringParts + { SynInterpolatedStringPart.String(fst $1, rhs parseState 1) :: SynInterpolatedStringPart.FillExpr $2 :: $3 } | INTERP_STRING_PART interpolatedStringParts { let rbrace = parseState.InputEndPosition 1 diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index c7dbc64bac..27098c6bd1 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -372,6 +372,11 @@ rozhraní s vícenásobným obecným vytvářením instancí + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute Povolit duplikát malými písmeny při atributu RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index d5800420f0..c89e0988f8 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -372,6 +372,11 @@ Schnittstellen mit mehrfacher generischer Instanziierung + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute DU in Kleinbuchstaben zulassen, wenn requireQualifiedAccess-Attribut diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index dcfce17569..de54c17c1f 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -372,6 +372,11 @@ interfaces con creación de instancias genéricas múltiples + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute Permitir DU en minúsculas con el atributo RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 590c4fb8e1..1780752360 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -372,6 +372,11 @@ interfaces avec plusieurs instanciations génériques + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute Autoriser les DU en minuscules pour l'attribut RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 70613984b7..1661484a63 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -372,6 +372,11 @@ interfacce con più creazioni di istanze generiche + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute Consentire l’unione discriminata minuscola quando l'attributo RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 84a9ca6ef7..a5a04b7c1b 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -372,6 +372,11 @@ 複数のジェネリックのインスタンス化を含むインターフェイス + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute RequireQualifiedAccess 属性の場合に小文字 DU を許可する diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 38ffac7d32..d419bd0d99 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -372,6 +372,11 @@ 여러 제네릭 인스턴스화가 포함된 인터페이스 + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute RequireQualifiedAccess 특성이 있는 경우 소문자 DU 허용 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index ac1d54f63c..65d582f379 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -372,6 +372,11 @@ interfejsy z wieloma ogólnymi wystąpieniami + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute Zezwalaj na małą literę DU, gdy występuje RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 6beb194626..93af3d22e7 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -372,6 +372,11 @@ interfaces com várias instanciações genéricas + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute Permitir DU em minúsculas quando o atributo RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 1b83dc7cc6..b13f061163 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -372,6 +372,11 @@ интерфейсы с множественным универсальным созданием экземпляра + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute Разрешить du в нижнем регистре, если атрибут RequireQualifiedAccess diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 43f5069b2e..ad43bfe169 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -372,6 +372,11 @@ birden çok genel örnek oluşturma içeren arabirimler + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute RequireQualifiedAccess özniteliğinde küçük harf DU'ya izin ver diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 91cad01e99..d7013ad94e 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -372,6 +372,11 @@ 具有多个泛型实例化的接口 + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute 当 RequireQualifiedAccess 属性时允许小写 DU diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index f12b3fd0b5..902612c1b6 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -372,6 +372,11 @@ 具有多個泛型具現化的介面 + + Optimizes interpolated strings in certain cases, by lowering to concatenation + Optimizes interpolated strings in certain cases, by lowering to concatenation + + Allow lowercase DU when RequireQualifiedAccess attribute RequireQualifiedAccess 屬性時允許小寫 DU diff --git a/tests/AheadOfTime/Trimming/check.ps1 b/tests/AheadOfTime/Trimming/check.ps1 index 4b9dcaebf1..8528710b76 100644 --- a/tests/AheadOfTime/Trimming/check.ps1 +++ b/tests/AheadOfTime/Trimming/check.ps1 @@ -42,4 +42,4 @@ function CheckTrim($root, $tfm, $outputfile, $expected_len) { CheckTrim -root "SelfContained_Trimming_Test" -tfm "net8.0" -outputfile "FSharp.Core.dll" -expected_len 287232 # Check net7.0 trimmed assemblies -CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net8.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 8821248 +CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net8.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 8820736 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/StringFormatAndInterpolation.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/StringFormatAndInterpolation.fs index 0ef7d23422..3038460f57 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/StringFormatAndInterpolation.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/StringFormatAndInterpolation.fs @@ -5,8 +5,8 @@ namespace EmittedIL open Xunit open FSharp.Test.Compiler -#if !DEBUG // sensitive to debug-level code coming across from debug FSharp.Core module ``StringFormatAndInterpolation`` = +#if !DEBUG // sensitive to debug-level code coming across from debug FSharp.Core [] let ``Interpolated string with no holes is reduced to a string or simple format when used in printf``() = FSharp """ @@ -34,3 +34,61 @@ IL_0017: ret"""] #endif + [] + let ``Interpolated string with 2 parts consisting only of strings is lowered to concat`` () = + FSharp $""" +module StringFormatAndInterpolation + +let f (s: string) = $"ab{{s}}" + """ + |> withLangVersionPreview + |> compile + |> shouldSucceed + |> verifyIL [""" +IL_0000: ldstr "ab" +IL_0005: ldarg.0 +IL_0006: call string [runtime]System.String::Concat(string, + string) +IL_000b: ret"""] + + [] + let ``Interpolated string with 3 parts consisting only of strings is lowered to concat`` () = + //let str = "$\"\"\"ab{\"c\"}d\"\"\"" + FSharp $""" +module StringFormatAndInterpolation + +let c = "c" +let str = $"ab{{c}}d" + """ + |> withLangVersionPreview + |> compile + |> shouldSucceed + |> verifyIL [""" +IL_0000: ldstr "ab" +IL_0005: ldstr "c" +IL_000a: ldstr "d" +IL_000f: call string [runtime]System.String::Concat(string, + string, + string)"""] + + [] + let ``Interpolated string with 4 parts consisting only of strings is lowered to concat`` () = + let str = "$\"\"\"a{\"b\"}{\"c\"}d\"\"\"" + FSharp $""" +module StringFormatAndInterpolation + +let str () = {str} + """ + |> withLangVersionPreview + |> compile + |> shouldSucceed + |> verifyIL [""" +IL_0000: ldstr "a" +IL_0005: ldstr "b" +IL_000a: ldstr "c" +IL_000f: ldstr "d" +IL_0014: call string [runtime]System.String::Concat(string, + string, + string, + string) +IL_0019: ret"""] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Language/InterpolatedStringsTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/InterpolatedStringsTests.fs index c8f2eafa93..7c82ac3d88 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/InterpolatedStringsTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/InterpolatedStringsTests.fs @@ -128,4 +128,49 @@ type Foo () = x """ |> compile - |> shouldSucceed \ No newline at end of file + |> shouldSucceed + + [] + // Test different number of interpolated string parts + [] + [] + [] + let ``Interpolated expressions are strings`` (strToPrint: string) = + Fsx $""" +let x = {strToPrint} +printfn "%%s" x + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + |> withStdOutContains "abcde" + + let ``Multiline interpolated expression is a string`` () = + let strToPrint = String.Join(Environment.NewLine, "$\"\"\"a", "b", "c", "{\"d\"}", "e\"\"\"") + Fsx $""" +let x = {strToPrint} +printfn "%%s" x + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + |> withStdOutContains """a +b +c +d +e""" + + [] + [] + [] + [] + let ``In FormattableString, interpolated expressions are strings`` (formattableStr: string, argCount: int) = + Fsx $""" +let x = {formattableStr} : System.FormattableString +assert(x.ArgumentCount = {argCount}) +printfn "%%s" (System.Globalization.CultureInfo "en-US" |> x.ToString) + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + |> withStdOutContains "abcde" \ No newline at end of file From f78cb7b8dc2deae4d9160815f791b395ea92af44 Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Fri, 23 Feb 2024 14:54:07 +0100 Subject: [PATCH 17/24] Add GetProjectSnapshotFromScript to FSharpChecker (#16735) * Initial attempt for GetProjectSnapshotFromScript * Add GetProjectSnapshotFromScript to service. * Address feedback from code review. * Assert both return the same results. * Remove old comment * Construct cache key in ComputeScriptClosure * Include stamp * Don't take projectSnapshot as input for ComputeScriptClosure * Add other flags * Add checksum directly. * Remove duplicate checksum * Use ISourceTextNew for Source * Mark API as experimental --- src/Compiler/Service/BackgroundCompiler.fs | 48 +++++ src/Compiler/Service/BackgroundCompiler.fsi | 14 ++ src/Compiler/Service/FSharpProjectSnapshot.fs | 2 +- src/Compiler/Service/TransparentCompiler.fs | 167 +++++++++++++++++- src/Compiler/Service/service.fs | 31 ++++ src/Compiler/Service/service.fsi | 28 +++ .../FSharpChecker/TransparentCompiler.fs | 19 +- ...ervice.SurfaceArea.netstandard20.debug.bsl | 1 + ...vice.SurfaceArea.netstandard20.release.bsl | 1 + 9 files changed, 300 insertions(+), 11 deletions(-) diff --git a/src/Compiler/Service/BackgroundCompiler.fs b/src/Compiler/Service/BackgroundCompiler.fs index 54bea5584a..d66847b5c1 100644 --- a/src/Compiler/Service/BackgroundCompiler.fs +++ b/src/Compiler/Service/BackgroundCompiler.fs @@ -123,6 +123,20 @@ type internal IBackgroundCompiler = userOpName: string -> Async + abstract GetProjectSnapshotFromScript: + fileName: string * + sourceText: ISourceTextNew * + previewEnabled: bool option * + loadedTimeStamp: System.DateTime option * + otherFlags: string array option * + useFsiAuxLib: bool option * + useSdkRefs: bool option * + sdkDirOverride: string option * + assumeDotNetFramework: bool option * + optionsStamp: int64 option * + userOpName: string -> + Async + abstract member GetSemanticClassificationForFile: fileName: string * options: FSharpProjectOptions * userOpName: string -> NodeCode @@ -1595,6 +1609,40 @@ type internal BackgroundCompiler userOpName ) + member _.GetProjectSnapshotFromScript + ( + fileName: string, + sourceText: ISourceTextNew, + previewEnabled: bool option, + loadedTimeStamp: DateTime option, + otherFlags: string array option, + useFsiAuxLib: bool option, + useSdkRefs: bool option, + sdkDirOverride: string option, + assumeDotNetFramework: bool option, + optionsStamp: int64 option, + userOpName: string + ) : Async = + async { + let! options, diagnostics = + self.GetProjectOptionsFromScript( + fileName, + sourceText, + previewEnabled, + loadedTimeStamp, + otherFlags, + useFsiAuxLib, + useSdkRefs, + sdkDirOverride, + assumeDotNetFramework, + optionsStamp, + userOpName + ) + + let! snapshot = FSharpProjectSnapshot.FromOptions(options, DocumentSource.FileSystem) + return snapshot, diagnostics + } + member _.GetSemanticClassificationForFile ( fileName: string, diff --git a/src/Compiler/Service/BackgroundCompiler.fsi b/src/Compiler/Service/BackgroundCompiler.fsi index 6d63c3b93e..cd7c163a0d 100644 --- a/src/Compiler/Service/BackgroundCompiler.fsi +++ b/src/Compiler/Service/BackgroundCompiler.fsi @@ -102,6 +102,20 @@ type internal IBackgroundCompiler = userOpName: string -> Async + abstract GetProjectSnapshotFromScript: + fileName: string * + sourceText: ISourceTextNew * + previewEnabled: bool option * + loadedTimeStamp: System.DateTime option * + otherFlags: string array option * + useFsiAuxLib: bool option * + useSdkRefs: bool option * + sdkDirOverride: string option * + assumeDotNetFramework: bool option * + optionsStamp: int64 option * + userOpName: string -> + Async + abstract GetSemanticClassificationForFile: fileName: string * snapshot: FSharpProjectSnapshot * userOpName: string -> NodeCode diff --git a/src/Compiler/Service/FSharpProjectSnapshot.fs b/src/Compiler/Service/FSharpProjectSnapshot.fs index a5ae2447db..7ab252ef73 100644 --- a/src/Compiler/Service/FSharpProjectSnapshot.fs +++ b/src/Compiler/Service/FSharpProjectSnapshot.fs @@ -123,7 +123,7 @@ type FSharpFileSnapshot(FileName: string, Version: string, GetSource: unit -> Ta /// A source file snapshot with loaded source text. type internal FSharpFileSnapshotWithSource - (FileName: string, SourceHash: ImmutableArray, Source: ISourceText, IsLastCompiland: bool, IsExe: bool) = + (FileName: string, SourceHash: ImmutableArray, Source: ISourceTextNew, IsLastCompiland: bool, IsExe: bool) = let version = lazy (SourceHash.ToBuilder().ToArray()) let stringVersion = lazy (version.Value |> BitConverter.ToString) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index 19d383d00b..e85488e773 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -1,6 +1,7 @@ namespace FSharp.Compiler.CodeAnalysis.TransparentCompiler open System +open System.Linq open System.Collections.Generic open System.Runtime.CompilerServices open System.Diagnostics @@ -377,26 +378,51 @@ type internal TransparentCompiler let ComputeScriptClosure (fileName: string) - (source: ISourceText) + (source: ISourceTextNew) (defaultFSharpBinariesDir: string) (useSimpleResolution: bool) (useFsiAuxLib: bool option) (useSdkRefs: bool option) (sdkDirOverride: string option) (assumeDotNetFramework: bool option) - (projectSnapshot: ProjectSnapshot) + (projectIdentifier: ProjectIdentifier) + (otherOptions: string list) + (stamp: int64 option) = + let useFsiAuxLib = defaultArg useFsiAuxLib true + let useSdkRefs = defaultArg useSdkRefs true + let assumeDotNetFramework = defaultArg assumeDotNetFramework false + + let key = + { new ICacheKey with + member _.GetKey() = fileName, projectIdentifier + member _.GetLabel() = $"ScriptClosure for %s{fileName}" + + member _.GetVersion() = + Md5Hasher.empty + |> Md5Hasher.addStrings + [| + yield! otherOptions + match stamp with + | None -> () + | Some stamp -> string stamp + |] + |> Md5Hasher.addBytes (source.GetChecksum().ToArray()) + |> Md5Hasher.addBool useFsiAuxLib + |> Md5Hasher.addBool useFsiAuxLib + |> Md5Hasher.addBool useSdkRefs + |> Md5Hasher.addBool assumeDotNetFramework + |> Md5Hasher.toString + } + caches.ScriptClosure.Get( - projectSnapshot.FileKey fileName, + key, node { - let useFsiAuxLib = defaultArg useFsiAuxLib true - let useSdkRefs = defaultArg useSdkRefs true let reduceMemoryUsage = ReduceMemoryFlag.Yes - let assumeDotNetFramework = defaultArg assumeDotNetFramework false let applyCompilerOptions tcConfig = let fsiCompilerOptions = GetCoreFsiCompilerOptions tcConfig - ParseCompilerOptions(ignore, fsiCompilerOptions, projectSnapshot.OtherOptions) + ParseCompilerOptions(ignore, fsiCompilerOptions, otherOptions) let closure = LoadClosure.ComputeClosureOfScriptText( @@ -665,7 +691,9 @@ type internal TransparentCompiler None None None - projectSnapshot + projectSnapshot.Identifier + projectSnapshot.OtherOptions + projectSnapshot.Stamp return (Some closure) } @@ -1521,7 +1549,9 @@ type internal TransparentCompiler (Some tcConfig.useSdkRefs) tcConfig.sdkDirOverride (Some tcConfig.assumeDotNetFramework) - projectSnapshot + projectSnapshot.Identifier + projectSnapshot.OtherOptions + projectSnapshot.Stamp let typedResults = FSharpCheckFileResults.Make( @@ -2111,6 +2141,125 @@ type internal TransparentCompiler userOpName ) + member this.GetProjectSnapshotFromScript + ( + fileName: string, + sourceText: ISourceTextNew, + previewEnabled: bool option, + loadedTimeStamp: DateTime option, + otherFlags: string array option, + useFsiAuxLib: bool option, + useSdkRefs: bool option, + sdkDirOverride: string option, + assumeDotNetFramework: bool option, + optionsStamp: int64 option, + userOpName: string + ) : Async = + use _ = + Activity.start + "BackgroundCompiler.GetProjectOptionsFromScript" + [| Activity.Tags.fileName, fileName; Activity.Tags.userOpName, userOpName |] + + async { + // Use the same default as the background compiler. + let useFsiAuxLib = defaultArg useFsiAuxLib true + let useSdkRefs = defaultArg useSdkRefs true + let previewEnabled = defaultArg previewEnabled false + + // Do we assume .NET Framework references for scripts? + let assumeDotNetFramework = defaultArg assumeDotNetFramework true + + let extraFlags = + if previewEnabled then + [| "--langversion:preview" |] + else + [||] + + let otherFlags = defaultArg otherFlags extraFlags + use diagnostics = new DiagnosticsScope(otherFlags |> Array.contains "--flaterrors") + + let useSimpleResolution = + otherFlags |> Array.exists (fun x -> x = "--simpleresolution") + + let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading + let projectFileName = fileName + ".fsproj" + + let currentSourceFile = + FSharpFileSnapshot.Create(fileName, sourceText.GetHashCode().ToString(), (fun () -> Task.FromResult sourceText)) + + let! loadClosure = + ComputeScriptClosure + fileName + sourceText + FSharpCheckerResultsSettings.defaultFSharpBinariesDir + useSimpleResolution + (Some useFsiAuxLib) + (Some useSdkRefs) + sdkDirOverride + (Some assumeDotNetFramework) + (projectFileName, fileName) + (List.ofArray otherFlags) + optionsStamp + |> Async.AwaitNodeCode + + let otherFlags = + [ + yield "--noframework" + yield "--warn:3" + yield! otherFlags + for code, _ in loadClosure.NoWarns do + yield "--nowarn:" + code + ] + + let sourceFiles = + loadClosure.SourceFiles + |> List.map (fun (sf, _) -> + if sf = fileName then + currentSourceFile + else + FSharpFileSnapshot.CreateFromFileSystem sf) + + let references = + loadClosure.References + |> List.map (fun (r, _) -> + let lastModified = FileSystem.GetLastWriteTimeShim r + + { + Path = r + LastModified = lastModified + }) + + let snapshot = + FSharpProjectSnapshot.Create( + fileName + ".fsproj", + None, + sourceFiles, + references, + otherFlags, + List.empty, + false, + true, + loadedTimeStamp, + Some(FSharpUnresolvedReferencesSet(loadClosure.UnresolvedReferences)), + loadClosure.OriginalLoadReferences, + optionsStamp + ) + + let diags = + loadClosure.LoadClosureRootFileDiagnostics + |> List.map (fun (exn, isError) -> + FSharpDiagnostic.CreateFromException( + exn, + isError, + range.Zero, + false, + otherFlags |> List.contains "--flaterrors", + None + )) + + return snapshot, (diags @ diagnostics.Diagnostics) + } + member this.GetSemanticClassificationForFile(fileName: string, snapshot: FSharpProjectSnapshot, userOpName: string) = node { ignore userOpName diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index 82b43827e1..94dce6286b 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -557,6 +557,37 @@ type FSharpChecker userOpName ) + /// For a given script file, get the ProjectSnapshot implied by the #load closure + member _.GetProjectSnapshotFromScript + ( + fileName, + source, + ?previewEnabled, + ?loadedTimeStamp, + ?otherFlags, + ?useFsiAuxLib, + ?useSdkRefs, + ?assumeDotNetFramework, + ?sdkDirOverride, + ?optionsStamp: int64, + ?userOpName: string + ) = + let userOpName = defaultArg userOpName "Unknown" + + backgroundCompiler.GetProjectSnapshotFromScript( + fileName, + source, + previewEnabled, + loadedTimeStamp, + otherFlags, + useFsiAuxLib, + useSdkRefs, + sdkDirOverride, + assumeDotNetFramework, + optionsStamp, + userOpName + ) + member _.GetProjectOptionsFromCommandLineArgs(projectFileName, argv, ?loadedTimeStamp, ?isInteractive, ?isEditing) = let isEditing = defaultArg isEditing false let isInteractive = defaultArg isInteractive false diff --git a/src/Compiler/Service/service.fsi b/src/Compiler/Service/service.fsi index b8e87b805f..cb8272b0f6 100644 --- a/src/Compiler/Service/service.fsi +++ b/src/Compiler/Service/service.fsi @@ -251,6 +251,34 @@ type public FSharpChecker = ?userOpName: string -> Async + /// Used to differentiate between scripts, to consider each script a separate project. Also used in formatted error messages. + /// The source for the file. + /// Is the preview compiler enabled. + /// Indicates when the script was loaded into the editing environment, + /// so that an 'unload' and 'reload' action will cause the script to be considered as a new project, + /// so that references are re-resolved. + /// Other flags for compilation. + /// Add a default reference to the FSharp.Compiler.Interactive.Settings library. + /// Use the implicit references from the .NET SDK. + /// Set up compilation and analysis for .NET Framework scripts. + /// Override the .NET SDK used for default references. + /// An optional unique stamp for the options. + /// An optional string used for tracing compiler operations associated with this request. + [] + member GetProjectSnapshotFromScript: + fileName: string * + source: ISourceTextNew * + ?previewEnabled: bool * + ?loadedTimeStamp: DateTime * + ?otherFlags: string[] * + ?useFsiAuxLib: bool * + ?useSdkRefs: bool * + ?assumeDotNetFramework: bool * + ?sdkDirOverride: string * + ?optionsStamp: int64 * + ?userOpName: string -> + Async + /// Get the FSharpProjectOptions implied by a set of command line arguments. /// /// Used to differentiate between projects and for the base directory of the project. diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs index cbc8e7690f..2adb305a2e 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs @@ -3,6 +3,7 @@ open System.Collections.Concurrent open System.Diagnostics open FSharp.Compiler.CodeAnalysis +open FSharp.Compiler.Text open Internal.Utilities.Collections open FSharp.Compiler.CodeAnalysis.TransparentCompiler open Internal.Utilities.Library.Extras @@ -894,4 +895,20 @@ let ``LoadClosure for script is recomputed after changes`` () = |> Seq.map (fun (k, g) -> k, g |> Seq.map fst |> Seq.toList) |> Map - Assert.Equal([Weakened; Requested; Started; Finished; Weakened; Requested; Started; Finished], closureComputations["FileFirst.fs"]) \ No newline at end of file + Assert.Equal([Weakened; Requested; Started; Finished; Weakened; Requested; Started; Finished], closureComputations["FileFirst.fs"]) + +[] +let ``Background compiler and Transparent compiler return the same options`` () = + async { + let backgroundChecker = FSharpChecker.Create(useTransparentCompiler = false) + let transparentChecker = FSharpChecker.Create(useTransparentCompiler = true) + let scriptName = Path.Combine(__SOURCE_DIRECTORY__, "script.fsx") + let content = SourceTextNew.ofString "" + + let! backgroundSnapshot, backgroundDiags = backgroundChecker.GetProjectSnapshotFromScript(scriptName, content) + let! transparentSnapshot, transparentDiags = transparentChecker.GetProjectSnapshotFromScript(scriptName, content) + Assert.Empty(backgroundDiags) + Assert.Empty(transparentDiags) + Assert.Equal(backgroundSnapshot.OtherOptions, transparentSnapshot.OtherOptions) + Assert.Equal(backgroundSnapshot.ReferencesOnDisk, transparentSnapshot.ReferencesOnDisk) + } 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 e526351eff..69fb762ea8 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 @@ -2067,6 +2067,7 @@ FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpParseFileResults,FSharp.Compiler.CodeAnalysis.FSharpCheckFileAnswer]] ParseAndCheckFileInProject(System.String, Int32, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpParseFileResults,FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults]] GetBackgroundCheckResultsForFileInProject(System.String, FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpProjectOptions,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Diagnostics.FSharpDiagnostic]]] GetProjectOptionsFromScript(System.String, FSharp.Compiler.Text.ISourceText, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.DateTime], Microsoft.FSharp.Core.FSharpOption`1[System.String[]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Int64], Microsoft.FSharp.Core.FSharpOption`1[System.String]) +FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Diagnostics.FSharpDiagnostic]]] GetProjectSnapshotFromScript(System.String, FSharp.Compiler.Text.ISourceTextNew, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.DateTime], Microsoft.FSharp.Core.FSharpOption`1[System.String[]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Int64], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.Diagnostics.FSharpDiagnostic[],System.Int32]] Compile(System.String[], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.Text.Range,FSharp.Compiler.Text.Range][]] MatchBraces(System.String, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.CodeAnalysis.FSharpParsingOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.Text.Range,FSharp.Compiler.Text.Range][]] MatchBraces(System.String, System.String, FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) 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 e526351eff..69fb762ea8 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 @@ -2067,6 +2067,7 @@ FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpParseFileResults,FSharp.Compiler.CodeAnalysis.FSharpCheckFileAnswer]] ParseAndCheckFileInProject(System.String, Int32, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpParseFileResults,FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults]] GetBackgroundCheckResultsForFileInProject(System.String, FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpProjectOptions,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Diagnostics.FSharpDiagnostic]]] GetProjectOptionsFromScript(System.String, FSharp.Compiler.Text.ISourceText, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.DateTime], Microsoft.FSharp.Core.FSharpOption`1[System.String[]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Int64], Microsoft.FSharp.Core.FSharpOption`1[System.String]) +FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.CodeAnalysis.ProjectSnapshot+FSharpProjectSnapshot,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Diagnostics.FSharpDiagnostic]]] GetProjectSnapshotFromScript(System.String, FSharp.Compiler.Text.ISourceTextNew, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.DateTime], Microsoft.FSharp.Core.FSharpOption`1[System.String[]], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Int64], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.Diagnostics.FSharpDiagnostic[],System.Int32]] Compile(System.String[], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.Text.Range,FSharp.Compiler.Text.Range][]] MatchBraces(System.String, FSharp.Compiler.Text.ISourceText, FSharp.Compiler.CodeAnalysis.FSharpParsingOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.FSharpAsync`1[System.Tuple`2[FSharp.Compiler.Text.Range,FSharp.Compiler.Text.Range][]] MatchBraces(System.String, System.String, FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[System.String]) From d071ddc854baf5fa016987360d5216739c251da1 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Fri, 23 Feb 2024 15:57:33 +0100 Subject: [PATCH 18/24] WIP: Use Arcade's NetCurrent (#16682) * WIP: Use Arcade's NetCurrent * WIP: Use Arcade's NetCurrent * Ordering of property groups * Build scripts? * Typo * Typo2 * Fix nuspec, please * Updates to support VMR build * Only set tfm option if SourceBuildBootstrapTfm is set * Fix ordering, set tfm before we account for building without arcade * Add rest of test projects * typos * Trimming is isolated and can't use global TFM value * Fix arcade interaction with our build props --------- Co-authored-by: Matt Thalman Co-authored-by: Petr --- Directory.Build.props | 43 +++++++--- FSharpTests.Directory.Build.props | 6 +- buildtools/AssemblyCheck/AssemblyCheck.fsproj | 2 +- .../FSharp.Compiler.Service_notshipped.fsproj | 4 +- buildtools/fslex/fslex.fsproj | 2 +- buildtools/fsyacc/fsyacc.fsproj | 2 +- eng/Build.ps1 | 80 ++++++++++--------- eng/DumpPackageRoot/DumpPackageRoot.csproj | 2 +- eng/SourceBuild.props | 6 +- eng/build-utils.ps1 | 9 ++- eng/build.sh | 17 ++-- eng/test-determinism.ps1 | 3 +- .../EditorService/EditorService.fsproj | 2 +- src/Compiler/FSharp.Compiler.Service.fsproj | 6 +- .../Microsoft.FSharp.Compiler.fsproj | 3 +- .../Microsoft.FSharp.Compiler.nuspec | 28 +++---- src/fsc/fscProject/fsc.fsproj | 6 +- src/fsi/fsiProject/fsi.fsproj | 6 +- .../BasicProvider.DesignTime.fsproj | 2 +- .../BasicProvider.Tests.fsproj | 2 +- .../BasicProvider/BasicProvider.fsproj | 2 +- .../FSharp.Build.UnitTests.fsproj | 4 +- .../FSharp.Compiler.ComponentTests.fsproj | 4 +- ...ompiler.Private.Scripting.UnitTests.fsproj | 4 +- .../FSharp.Compiler.Service.Tests.fsproj | 4 +- .../FSharp.Compiler.UnitTests.fsproj | 4 +- .../FSharp.Core.UnitTests.fsproj | 4 +- .../FSharp.Test.Utilities.fsproj | 4 +- .../MicroPerf/CS/MicroPerfCSharp.csproj | 2 +- .../MicroPerf/MicroPerf.fsproj | 2 +- .../TaskPerf/TaskPerf/TaskPerf.fsproj | 2 +- .../TaskPerfCSharp/TaskPerfCSharp.csproj | 2 +- .../HistoricalBenchmark.Runner.fsproj | 2 +- .../HistoricalBenchmark.fsproj | 2 +- .../FSharp.Compiler.Benchmarks.fsproj | 2 +- .../FCSSourceFiles/FCSSourceFiles.fsproj | 2 +- .../FSharp.Benchmarks.Common.fsproj | 2 +- tests/fsharp/FSharpSuite.Tests.fsproj | 4 +- .../Sample_ConsoleApp_net7.fsproj | 6 +- .../Sample_ConsoleApp_net7.fsproj | 6 +- .../LocalCompilerAndFslib.fsproj | 6 +- .../tailcallaltattr.fsproj | 2 +- 42 files changed, 172 insertions(+), 131 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index ed0556c07f..3dd057f702 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,12 +4,12 @@ $(FSharpLangVersion) $(MSBuildThisFileDirectory) true + net8.0 @@ -21,7 +21,7 @@ true - + false @@ -30,15 +30,40 @@ $(MSBuildThisFileDirectory)artifacts/ $(ArtifactsDir)/bin/$(MSBuildProjectName)/$(Configuration)/ $(ArtifactsDir)obj/$(MSBuildProjectName)/$(Configuration)/ - $(ArtifactsDir)/bin/fslex/$(Configuration)/net8.0/fslex.dll - $(ArtifactsDir)/bin/fsyacc/$(Configuration)/net8.0/fsyacc.dll + + $(ArtifactsDir)/bin/fslex/$(Configuration)/$(FSharpNetCoreProductDefaultTargetFramework)/fslex.dll + $(ArtifactsDir)/bin/fsyacc/$(Configuration)/$(FSharpNetCoreProductDefaultTargetFramework)/fsyacc.dll NO_CHECKNULLS;BUILDING_WITH_LKG;NO_NULLCHECKING_LIB_SUPPORT;$(DefineConstants) + - + + + + + + + $(NetCurrent) + + + + + $(FSharpNetCoreProductDefaultTargetFramework) + + + - - + + diff --git a/FSharpTests.Directory.Build.props b/FSharpTests.Directory.Build.props index 03c26b4b07..2be5d4f270 100644 --- a/FSharpTests.Directory.Build.props +++ b/FSharpTests.Directory.Build.props @@ -22,18 +22,18 @@ $([System.IO.Path]::GetDirectoryName('$(DOTNET_HOST_PATH)')) dotnet.exe dotnet - $(MSBuildThisFileDirectory)artifacts\bin\fsc\$(Configuration)\net8.0\fsc.dll + $(MSBuildThisFileDirectory)artifacts\bin\fsc\$(Configuration)\$(FSharpNetCoreProductTargetFramework)\fsc.dll $([System.IO.Path]::GetDirectoryName('$(DOTNET_HOST_PATH)')) dotnet.exe dotnet - $(MSBuildThisFileDirectory)artifacts\bin\fsi\$(Configuration)\net8.0\fsi.dll + $(MSBuildThisFileDirectory)artifacts\bin\fsi\$(Configuration)\$(FSharpNetCoreProductTargetFramework)\fsi.dll <_FSharpBuildTargetFramework Condition="'$(MSBuildRuntimeType)'!='Core'">net472 - <_FSharpBuildTargetFramework Condition="'$(MSBuildRuntimeType)'=='Core'">net8.0 + <_FSharpBuildTargetFramework Condition="'$(MSBuildRuntimeType)'=='Core'">$(FSharpNetCoreProductTargetFramework) <_FSharpBuildBinPath>$(MSBuildThisFileDirectory)artifacts\bin\fsc\$(Configuration)\$(_FSharpBuildTargetFramework) $(_FSharpBuildBinPath)\FSharp.Build.dll diff --git a/buildtools/AssemblyCheck/AssemblyCheck.fsproj b/buildtools/AssemblyCheck/AssemblyCheck.fsproj index 46ffb722cd..1f01406c73 100644 --- a/buildtools/AssemblyCheck/AssemblyCheck.fsproj +++ b/buildtools/AssemblyCheck/AssemblyCheck.fsproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(FSharpNetCoreProductTargetFramework) true false diff --git a/buildtools/checkpackages/FSharp.Compiler.Service_notshipped.fsproj b/buildtools/checkpackages/FSharp.Compiler.Service_notshipped.fsproj index 514b1f4ddf..8a0874bff6 100644 --- a/buildtools/checkpackages/FSharp.Compiler.Service_notshipped.fsproj +++ b/buildtools/checkpackages/FSharp.Compiler.Service_notshipped.fsproj @@ -1,9 +1,9 @@  - + - net8.0 + $(FSharpNetCoreProductTargetFramework) true $(MSBuildProjectDirectory)\..\..\artifacts\tmp\$([System.Guid]::NewGuid()) $(CachePath)\bin diff --git a/buildtools/fslex/fslex.fsproj b/buildtools/fslex/fslex.fsproj index 674dde7c75..50c1e4e366 100644 --- a/buildtools/fslex/fslex.fsproj +++ b/buildtools/fslex/fslex.fsproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(FSharpNetCoreProductTargetFramework) true false LatestMajor diff --git a/buildtools/fsyacc/fsyacc.fsproj b/buildtools/fsyacc/fsyacc.fsproj index fc072b7cf0..0cc67482b3 100644 --- a/buildtools/fsyacc/fsyacc.fsproj +++ b/buildtools/fsyacc/fsyacc.fsproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(FSharpNetCoreProductTargetFramework) true false LatestMajor diff --git a/eng/Build.ps1 b/eng/Build.ps1 index fe7eb56a5b..049ba91217 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -36,6 +36,7 @@ param ( [switch][Alias('proto')]$bootstrap, [string]$bootstrapConfiguration = "Proto", [string]$bootstrapTfm = "net472", + [string]$fsharpNetCoreProductTfm = "net8.0", [switch][Alias('bl')]$binaryLog = $true, [switch][Alias('nobl')]$excludeCIBinaryLog = $false, [switch][Alias('nolog')]$noBinaryLog = $false, @@ -76,6 +77,9 @@ $ErrorActionPreference = "Stop" $BuildCategory = "" $BuildMessage = "" +$desktopTargetFramework = "net472" +$coreclrTargetFramework = "net8.0" + function Print-Usage() { Write-Host "Common settings:" Write-Host " -configuration Build configuration: 'Debug' or 'Release' (short: -c)" @@ -229,11 +233,11 @@ function Process-Arguments() { function Update-Arguments() { if ($script:noVisualStudio) { - $script:bootstrapTfm = "net8.0" + $script:bootstrapTfm = $script:coreclrTargetFramework $script:msbuildEngine = "dotnet" } - if ($bootstrapTfm -eq "net8.0") { + if ($bootstrapTfm -eq $script:coreclrTargetFramework) { if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.runtimeconfig.json")) { $script:bootstrap = $True } @@ -255,7 +259,7 @@ function BuildSolution([string] $solutionName, $nopack) { $officialBuildId = if ($official) { $env:BUILD_BUILDNUMBER } else { "" } $toolsetBuildProj = InitializeToolset $quietRestore = !$ci - $testTargetFrameworks = if ($testCoreClr) { "net8.0" } else { "" } + $testTargetFrameworks = if ($testCoreClr) { $script:coreclrTargetFramework } else { "" } # Do not set the property to true explicitly, since that would override value projects might set. $suppressExtensionDeployment = if (!$deployExtensions) { "/p:DeployExtension=false" } else { "" } @@ -312,8 +316,8 @@ function UpdatePath() { } TestAndAddToPath $subdir - TestAndAddToPath "$ArtifactsDir\bin\fsc\$configuration\net472" - TestAndAddToPath "$ArtifactsDir\bin\fsiAnyCpu\$configuration\net472" + TestAndAddToPath "$ArtifactsDir\bin\fsc\$configuration\$script:desktopTargetFramework" + TestAndAddToPath "$ArtifactsDir\bin\fsiAnyCpu\$configuration\$script:desktopTargetFramework" } function VerifyAssemblyVersionsAndSymbols() { @@ -565,18 +569,16 @@ try { $script:BuildCategory = "Test" $script:BuildMessage = "Failure running tests" - $desktopTargetFramework = "net472" - $coreclrTargetFramework = "net8.0" if ($testCoreClr) { - $bgJob = TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true + $bgJob = TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" + TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" # Collect output from background jobs Wait-job $bgJob | out-null @@ -584,14 +586,14 @@ try { } if ($testDesktop) { - $bgJob = TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true + $bgJob = TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" -asBackgroundJob $true - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true + TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" + TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" + TestUsingXUnit -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\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Build.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" # Collect output from background jobs Wait-job $bgJob | out-null @@ -609,7 +611,7 @@ try { UpdatePath $env:HOSTED_COMPILER = 1 $env:CSC_PIPE = "$nugetPackages\Microsoft.Net.Compilers\4.3.0-1.22220.8\tools\csc.exe" - $env:FSCOREDLLPATH = "$ArtifactsDir\bin\fsc\$configuration\net472\FSharp.Core.dll" + $env:FSCOREDLLPATH = "$ArtifactsDir\bin\fsc\$configuration\$script:desktopTargetFramework\FSharp.Core.dll" $env:LINK_EXE = "$RepoRoot\tests\fsharpqa\testenv\bin\link\link.exe" $env:OSARCH = $env:PROCESSOR_ARCHITECTURE @@ -626,46 +628,46 @@ try { } if ($testFSharpCore) { - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Core.UnitTests\" } if ($testCompiler) { - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true + TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" + TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.UnitTests\" } if ($testCompilerComponentTests) { - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.ComponentTests\" -noTestFilter $true } if ($testCompilerService) { - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" - TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" + TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" + TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Service.Tests\" } if ($testCambridge) { - TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" - TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" + TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" + TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharpSuite.Tests\" } if ($testScripting) { - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" - TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\tests\FSharp.Compiler.Private.Scripting.UnitTests\FSharp.Compiler.Private.Scripting.UnitTests.fsproj" -targetFramework $script:coreclrTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Compiler.Private.Scripting.UnitTests\" + TestUsingXUnit -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) { - TestUsingXUnit -testProject "$RepoRoot\vsintegration\tests\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj" - TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\VisualFSharp.UnitTests\" + TestUsingXUnit -testProject "$RepoRoot\vsintegration\tests\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj" + TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\VisualFSharp.UnitTests\" } if ($testIntegration) { - TestUsingXUnit -testProject "$RepoRoot\vsintegration\tests\FSharp.Editor.IntegrationTests\FSharp.Editor.IntegrationTests.csproj" -targetFramework $desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Editor.IntegrationTests\" + TestUsingXUnit -testProject "$RepoRoot\vsintegration\tests\FSharp.Editor.IntegrationTests\FSharp.Editor.IntegrationTests.csproj" -targetFramework $script:desktopTargetFramework -testadapterpath "$ArtifactsDir\bin\FSharp.Editor.IntegrationTests\" } if ($testAOT) { diff --git a/eng/DumpPackageRoot/DumpPackageRoot.csproj b/eng/DumpPackageRoot/DumpPackageRoot.csproj index 5cbfdca4db..da79505fcf 100644 --- a/eng/DumpPackageRoot/DumpPackageRoot.csproj +++ b/eng/DumpPackageRoot/DumpPackageRoot.csproj @@ -3,7 +3,7 @@ - net8.0 + $(FSharpNetCoreProductTargetFramework) diff --git a/eng/SourceBuild.props b/eng/SourceBuild.props index 3ac9370d1a..550215bd64 100644 --- a/eng/SourceBuild.props +++ b/eng/SourceBuild.props @@ -24,6 +24,10 @@ + + + --tfm $(SourceBuildBootstrapTfm) + diff --git a/eng/build-utils.ps1 b/eng/build-utils.ps1 index a0c5299cb9..f73195c7cc 100644 --- a/eng/build-utils.ps1 +++ b/eng/build-utils.ps1 @@ -14,6 +14,7 @@ $nodeReuse = if (Test-Path variable:nodeReuse) { $nodeReuse } else { $false } $bootstrapDir = if (Test-Path variable:bootstrapDir) { $bootstrapDir } else { "" } $bootstrapConfiguration = if (Test-Path variable:bootstrapConfiguration) { $bootstrapConfiguration } else { "Proto" } $bootstrapTfm = if (Test-Path variable:bootstrapTfm) { $bootstrapTfm } else { "net472" } +$fsharpNetCoreProductTfm = if (Test-Path variable:fsharpNetCoreProductTfm) { $fsharpNetCoreProductTfm } else { "net8.0" } $properties = if (Test-Path variable:properties) { $properties } else { @() } function GetProjectOutputBinary([string]$fileName, [string]$projectName = "", [string]$configuration = $script:configuration, [string]$tfm = "net472", [string]$rid = "", [bool]$published = $false) { @@ -230,7 +231,7 @@ function Run-MSBuild([string]$projectFilePath, [string]$buildArgs = "", [string] # Important to not set $script:bootstrapDir here yet as we're actually in the process of # building the bootstrap. function Make-BootstrapBuild() { - Write-Host "Building bootstrap '$bootstrapTfm' compiler" + Write-Host "Building bootstrap '$bootstrapTfm' compiler with '$fsharpNetCoreProductTfm' .NET Core product TFM" $dir = Join-Path $ArtifactsDir "Bootstrap" Remove-Item -re $dir -ErrorAction SilentlyContinue @@ -251,9 +252,9 @@ function Make-BootstrapBuild() { } Exec-Console $dotnetExe $args - Copy-Item "$ArtifactsDir\bin\fslex\$bootstrapConfiguration\net8.0" -Destination "$dir\fslex" -Force -Recurse - Copy-Item "$ArtifactsDir\bin\fsyacc\$bootstrapConfiguration\net8.0" -Destination "$dir\fsyacc" -Force -Recurse - Copy-Item "$ArtifactsDir\bin\AssemblyCheck\$bootstrapConfiguration\net8.0" -Destination "$dir\AssemblyCheck" -Force -Recurse + Copy-Item "$ArtifactsDir\bin\fslex\$bootstrapConfiguration\$fsharpNetCoreProductTfm" -Destination "$dir\fslex" -Force -Recurse + Copy-Item "$ArtifactsDir\bin\fsyacc\$bootstrapConfiguration\$fsharpNetCoreProductTfm" -Destination "$dir\fsyacc" -Force -Recurse + Copy-Item "$ArtifactsDir\bin\AssemblyCheck\$bootstrapConfiguration\$fsharpNetCoreProductTfm" -Destination "$dir\AssemblyCheck" -Force -Recurse # prepare compiler $protoProject = "`"$RepoRoot\proto.sln`"" diff --git a/eng/build.sh b/eng/build.sh index b8915397d2..6e5d09b79d 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -34,6 +34,7 @@ usage() echo " --skipBuild Do not run the build" echo " --prepareMachine Prepare machine for CI run, clean up processes after build" echo " --sourceBuild Simulate building for source-build" + echo " --tfm Override the default target framework" echo "" echo "Command line arguments starting with '/p:' are passed through to MSBuild." } @@ -72,6 +73,8 @@ properties="" docker=false args="" +tfm="net8.0" # This needs to be changed every time it's bumped by arcade/us. + BuildCategory="" BuildMessage="" @@ -149,6 +152,10 @@ while [[ $# > 0 ]]; do --sourcebuild) source_build=true ;; + --tfm) + tfm=$2 + shift + ;; /p:*) properties="$properties $1" ;; @@ -269,8 +276,8 @@ function BuildSolution { MSBuild "$repo_root/buildtools/buildtools.proj" /restore "$bltools" /p:Configuration=$bootstrap_config mkdir -p "$bootstrap_dir" - cp -pr $artifacts_dir/bin/fslex/$bootstrap_config/net8.0 $bootstrap_dir/fslex - cp -pr $artifacts_dir/bin/fsyacc/$bootstrap_config/net8.0 $bootstrap_dir/fsyacc + cp -pr $artifacts_dir/bin/fslex/$bootstrap_config/$tfm $bootstrap_dir/fslex + cp -pr $artifacts_dir/bin/fsyacc/$bootstrap_config/$tfm $bootstrap_dir/fsyacc fi if [ ! -f "$bootstrap_dir/fsc.exe" ]; then local bltools="" @@ -279,7 +286,7 @@ function BuildSolution { fi BuildMessage="Error building bootstrap" MSBuild "$repo_root/Proto.sln" /restore "$bltools" /p:Configuration=$bootstrap_config - cp -pr $artifacts_dir/bin/fsc/$bootstrap_config/net8.0 $bootstrap_dir/fsc + cp -pr $artifacts_dir/bin/fsc/$bootstrap_config/$tfm $bootstrap_dir/fsc fi fi @@ -321,7 +328,7 @@ InitializeDotNetCli $restore BuildSolution if [[ "$test_core_clr" == true ]]; then - coreclrtestframework=net8.0 + coreclrtestframework=$tfm TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj" --targetframework $coreclrtestframework --notestfilter TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj" --targetframework $coreclrtestframework --notestfilter TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj" --targetframework $coreclrtestframework @@ -331,7 +338,7 @@ if [[ "$test_core_clr" == true ]]; then fi if [[ "$test_compilercomponent_tests" == true ]]; then - coreclrtestframework=net8.0 + coreclrtestframework=$tfm TestUsingNUnit --testproject "$repo_root/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj" --targetframework $coreclrtestframework --notestfilter fi diff --git a/eng/test-determinism.ps1 b/eng/test-determinism.ps1 index 5b9a079f07..499c1187a0 100644 --- a/eng/test-determinism.ps1 +++ b/eng/test-determinism.ps1 @@ -378,9 +378,10 @@ try { $script:bootstrap = $true $script:bootstrapConfiguration = "Proto" $script:bootstrapTfm = "net472" + $script:fsharpNetCoreProductTfm = "net8.0" if ($script:msbuildEngine -eq "dotnet") { - $script.bootstrapTfm = "net8.0" + $script.bootstrapTfm = $script:fsharpNetCoreProductTfm } $bootstrapDir = Make-BootstrapBuild diff --git a/fcs-samples/EditorService/EditorService.fsproj b/fcs-samples/EditorService/EditorService.fsproj index e4103999fc..214bb75afc 100644 --- a/fcs-samples/EditorService/EditorService.fsproj +++ b/fcs-samples/EditorService/EditorService.fsproj @@ -1,7 +1,7 @@  - $(FcsTargetNetFxFramework);net8.0 + $(FcsTargetNetFxFramework);$(FSharpNetCoreProductTargetFramework) true Exe false diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj index dd7b6e25c1..6a52de4602 100644 --- a/src/Compiler/FSharp.Compiler.Service.fsproj +++ b/src/Compiler/FSharp.Compiler.Service.fsproj @@ -543,15 +543,15 @@ - TargetFramework=net8.0 + TargetFramework=$(FSharpNetCoreProductTargetFramework) compile - TargetFramework=net8.0 + TargetFramework=$(FSharpNetCoreProductTargetFramework) compile - TargetFramework=net8.0 + TargetFramework=$(FSharpNetCoreProductTargetFramework) compile diff --git a/src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.fsproj b/src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.fsproj index a427f7006d..7c186a76bb 100644 --- a/src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.fsproj +++ b/src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.fsproj @@ -3,7 +3,7 @@ true Exe - net8.0 + $(FSharpNetCoreProductTargetFramework) Microsoft.FSharp.Compiler.nuspec true .NET Core compatible version of the F# compiler fsc.exe. @@ -24,6 +24,7 @@ + diff --git a/src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.nuspec b/src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.nuspec index ca36309d5d..24df391b69 100644 --- a/src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.nuspec +++ b/src/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.nuspec @@ -4,7 +4,7 @@ $CommonMetadataElements$ en-US - + @@ -26,16 +26,16 @@ this approach gives a very small deployment. Which is kind of necessary. --> - - - - - - + + + + + + + target="lib\$fSharpNetCoreProductTargetFramework$" /> + target="lib\$fSharpNetCoreProductTargetFramework$" /> @@ -45,14 +45,14 @@ - + + target="lib\$fSharpNetCoreProductTargetFramework$" /> - + target="lib\$fSharpNetCoreProductTargetFramework$" /> + + target="lib\$fSharpNetCoreProductTargetFramework$" /> diff --git a/src/fsc/fscProject/fsc.fsproj b/src/fsc/fscProject/fsc.fsproj index 64c4651a7f..b382709200 100644 --- a/src/fsc/fscProject/fsc.fsproj +++ b/src/fsc/fscProject/fsc.fsproj @@ -3,15 +3,15 @@ - net472;net8.0 - net8.0 + net472;$(FSharpNetCoreProductTargetFramework) + $(FSharpNetCoreProductTargetFramework) x86 Debug;Release;Proto;ReleaseCompressed net472 - net8.0 + $(FSharpNetCoreProductTargetFramework) x86 diff --git a/src/fsi/fsiProject/fsi.fsproj b/src/fsi/fsiProject/fsi.fsproj index dd17f8bd53..653122fc76 100644 --- a/src/fsi/fsiProject/fsi.fsproj +++ b/src/fsi/fsiProject/fsi.fsproj @@ -3,15 +3,15 @@ - net472;net8.0 - net8.0 + net472;$(FSharpNetCoreProductTargetFramework) + $(FSharpNetCoreProductTargetFramework) x86 Debug;Release;Proto;ReleaseCompressed net472 - net8.0 + $(FSharpNetCoreProductTargetFramework) x86 diff --git a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj index b05e1882f6..ba15e56c35 100644 --- a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj +++ b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.DesignTime/BasicProvider.DesignTime.fsproj @@ -2,7 +2,7 @@ Library - net8.0;net472 + $(FSharpNetCoreProductTargetFramework);net472 typeproviders NO_GENERATIVE IS_DESIGNTIME diff --git a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj index 5da0cbb3bf..da2c065fe4 100644 --- a/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj +++ b/tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj @@ -2,7 +2,7 @@ Library - net8.0 + $(FSharpNetCoreProductTargetFramework) $(TestTargetFramework) false NO_GENERATIVE diff --git a/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj b/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj index 96006f0667..4a8d1df230 100644 --- a/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj +++ b/tests/EndToEndBuildTests/BasicProvider/BasicProvider/BasicProvider.fsproj @@ -2,7 +2,7 @@ Library - net8.0;net472 + $(FSharpNetCoreProductTargetFramework);net472 typeproviders $(FSharpCoreShippedPackageVersionValue) typeproviders diff --git a/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj b/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj index e3c796d0bd..0a2421f326 100644 --- a/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj +++ b/tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj @@ -3,8 +3,8 @@ - net472;net8.0 - net8.0 + net472;$(FSharpNetCoreProductTargetFramework) + $(FSharpNetCoreProductTargetFramework) Library true xunit diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index ec4fc441f2..ebfe6938aa 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -3,8 +3,8 @@ - net472;net8.0 - net8.0 + net472;$(FSharpNetCoreProductTargetFramework) + $(FSharpNetCoreProductTargetFramework) Library false true diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj index cdfd467e5c..8f69b337c5 100644 --- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj +++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharp.Compiler.Private.Scripting.UnitTests.fsproj @@ -2,8 +2,8 @@ - net472;net8.0 - net8.0 + net472;$(FSharpNetCoreProductTargetFramework) + $(FSharpNetCoreProductTargetFramework) Library true xunit diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 780ba10f3f..59b5fc43d6 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -3,8 +3,8 @@ Exe - net472;net8.0 - net8.0 + net472;$(FSharpNetCoreProductTargetFramework) + $(FSharpNetCoreProductTargetFramework) $(NoWarn);44;75; true false diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj index 0e4b91b42a..dd3e21cea9 100644 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj @@ -3,8 +3,8 @@ - net472;net8.0 - net8.0 + net472;$(FSharpNetCoreProductTargetFramework) + $(FSharpNetCoreProductTargetFramework) Library true $(DefineConstants);ASSUME_PREVIEW_FSHARP_CORE diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj index 4b6c5c5348..9acbcef398 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj +++ b/tests/FSharp.Core.UnitTests/FSharp.Core.UnitTests.fsproj @@ -3,8 +3,8 @@ - net8.0;net472 - net8.0 + $(FSharpNetCoreProductTargetFramework);net472 + $(FSharpNetCoreProductTargetFramework) Library FSharp.Core.UnitTests diff --git a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj index 8c18161775..0bee6d1e01 100644 --- a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj +++ b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj @@ -1,8 +1,8 @@  - net472;net8.0 - net8.0 + net472;$(FSharpNetCoreProductTargetFramework) + $(FSharpNetCoreProductTargetFramework) win-x86;win-x64;linux-x64;osx-x64 $(AssetTargetFallback);portable-net45+win8+wp8+wpa81 true diff --git a/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/CS/MicroPerfCSharp.csproj b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/CS/MicroPerfCSharp.csproj index 50bba8f6f2..168c8b546e 100644 --- a/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/CS/MicroPerfCSharp.csproj +++ b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/CS/MicroPerfCSharp.csproj @@ -1,7 +1,7 @@ - net8.0 + $(FSharpNetCoreProductTargetFramework) Library 8.0 diff --git a/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/MicroPerf.fsproj b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/MicroPerf.fsproj index 919c4cc073..c96d342298 100644 --- a/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/MicroPerf.fsproj +++ b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/MicroPerf.fsproj @@ -1,6 +1,6 @@ - net8.0 + $(FSharpNetCoreProductTargetFramework) Exe true diff --git a/tests/benchmarks/CompiledCodeBenchmarks/TaskPerf/TaskPerf/TaskPerf.fsproj b/tests/benchmarks/CompiledCodeBenchmarks/TaskPerf/TaskPerf/TaskPerf.fsproj index 9706167ff6..31d404fb06 100644 --- a/tests/benchmarks/CompiledCodeBenchmarks/TaskPerf/TaskPerf/TaskPerf.fsproj +++ b/tests/benchmarks/CompiledCodeBenchmarks/TaskPerf/TaskPerf/TaskPerf.fsproj @@ -1,7 +1,7 @@  - net8.0 + $(FSharpNetCoreProductTargetFramework) Exe true diff --git a/tests/benchmarks/CompiledCodeBenchmarks/TaskPerf/TaskPerfCSharp/TaskPerfCSharp.csproj b/tests/benchmarks/CompiledCodeBenchmarks/TaskPerf/TaskPerfCSharp/TaskPerfCSharp.csproj index d23714e40f..29148a7450 100644 --- a/tests/benchmarks/CompiledCodeBenchmarks/TaskPerf/TaskPerfCSharp/TaskPerfCSharp.csproj +++ b/tests/benchmarks/CompiledCodeBenchmarks/TaskPerf/TaskPerfCSharp/TaskPerfCSharp.csproj @@ -1,7 +1,7 @@  - net8.0 + $(FSharpNetCoreProductTargetFramework) Library 8.0 diff --git a/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.Runner/HistoricalBenchmark.Runner.fsproj b/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.Runner/HistoricalBenchmark.Runner.fsproj index fe6d95f905..1781b4784d 100644 --- a/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.Runner/HistoricalBenchmark.Runner.fsproj +++ b/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.Runner/HistoricalBenchmark.Runner.fsproj @@ -1,7 +1,7 @@ - net8.0 + $(FSharpNetCoreProductTargetFramework) true HistoricalBenchmark.Utilities $(NoWarn);NETSDK1206 diff --git a/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.fsproj b/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.fsproj index 09ca5cb691..48cfa7b497 100644 --- a/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.fsproj +++ b/tests/benchmarks/FCSBenchmarks/BenchmarkComparison/HistoricalBenchmark.fsproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(FSharpNetCoreProductTargetFramework) true Release diff --git a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj index 043de02d37..c7a873a2cc 100644 --- a/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj +++ b/tests/benchmarks/FCSBenchmarks/CompilerServiceBenchmarks/FSharp.Compiler.Benchmarks.fsproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(FSharpNetCoreProductTargetFramework) true false diff --git a/tests/benchmarks/FCSBenchmarks/FCSSourceFiles/FCSSourceFiles.fsproj b/tests/benchmarks/FCSBenchmarks/FCSSourceFiles/FCSSourceFiles.fsproj index 92255adb46..265ab45ac1 100644 --- a/tests/benchmarks/FCSBenchmarks/FCSSourceFiles/FCSSourceFiles.fsproj +++ b/tests/benchmarks/FCSBenchmarks/FCSSourceFiles/FCSSourceFiles.fsproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(FSharpNetCoreProductTargetFramework) true diff --git a/tests/benchmarks/FSharp.Benchmarks.Common/FSharp.Benchmarks.Common.fsproj b/tests/benchmarks/FSharp.Benchmarks.Common/FSharp.Benchmarks.Common.fsproj index 2e6b2e9ceb..615a5ab3a7 100644 --- a/tests/benchmarks/FSharp.Benchmarks.Common/FSharp.Benchmarks.Common.fsproj +++ b/tests/benchmarks/FSharp.Benchmarks.Common/FSharp.Benchmarks.Common.fsproj @@ -1,7 +1,7 @@  - net8.0 + $(FSharpNetCoreProductTargetFramework) true diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index b6d69d8ae1..ac97046351 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -2,8 +2,8 @@ - net472;net8.0 - net8.0 + net472;$(FSharpNetCoreProductTargetFramework) + $(FSharpNetCoreProductTargetFramework) win-x86;win-x64 $(AssetTargetFallback);portable-net45+win8+wp8+wpa81 true diff --git a/tests/projects/Sample_ConsoleApp_FileSystemTests/Sample_ConsoleApp_net7.fsproj b/tests/projects/Sample_ConsoleApp_FileSystemTests/Sample_ConsoleApp_net7.fsproj index 13d42aeb28..6fa21d9b26 100644 --- a/tests/projects/Sample_ConsoleApp_FileSystemTests/Sample_ConsoleApp_net7.fsproj +++ b/tests/projects/Sample_ConsoleApp_FileSystemTests/Sample_ConsoleApp_net7.fsproj @@ -2,13 +2,13 @@ Exe - net8.0 + $(FSharpNetCoreProductTargetFramework) true - $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/net8.0/fsc.dll - $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/net8.0/fsc.dll + $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/$(FSharpNetCoreProductTargetFramework)/fsc.dll + $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/$(FSharpNetCoreProductTargetFramework)/fsc.dll False True diff --git a/tests/projects/Sample_ConsoleApp_net7/Sample_ConsoleApp_net7.fsproj b/tests/projects/Sample_ConsoleApp_net7/Sample_ConsoleApp_net7.fsproj index bf06c1ce7a..94e78cddcf 100644 --- a/tests/projects/Sample_ConsoleApp_net7/Sample_ConsoleApp_net7.fsproj +++ b/tests/projects/Sample_ConsoleApp_net7/Sample_ConsoleApp_net7.fsproj @@ -2,13 +2,13 @@ Exe - net8.0 + $(FSharpNetCoreProductTargetFramework) preview - $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/net8.0/fsc.dll - $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/net8.0/fsc.dll + $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/$(FSharpNetCoreProductTargetFramework)/fsc.dll + $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/$(FSharpNetCoreProductTargetFramework)/fsc.dll False True diff --git a/tests/projects/Sample_Local_Compiler_and_FSLib/LocalCompilerAndFslib.fsproj b/tests/projects/Sample_Local_Compiler_and_FSLib/LocalCompilerAndFslib.fsproj index c2164b6566..4f47ab1a71 100644 --- a/tests/projects/Sample_Local_Compiler_and_FSLib/LocalCompilerAndFslib.fsproj +++ b/tests/projects/Sample_Local_Compiler_and_FSLib/LocalCompilerAndFslib.fsproj @@ -2,15 +2,15 @@ Exe - net8.0 + $(FSharpNetCoreProductTargetFramework) preview true true - $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/net8.0/fsc.dll - $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/net8.0/fsc.dll + $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/$(FSharpNetCoreProductTargetFramework)/fsc.dll + $(MSBuildThisFileDirectory)../../../artifacts/bin/fsc/Debug/$(FSharpNetCoreProductTargetFramework)/fsc.dll False True diff --git a/tests/projects/misc/SelfDefinedTailCallAttribute/tailcallaltattr.fsproj b/tests/projects/misc/SelfDefinedTailCallAttribute/tailcallaltattr.fsproj index 92c5ae861d..45f9002aa1 100644 --- a/tests/projects/misc/SelfDefinedTailCallAttribute/tailcallaltattr.fsproj +++ b/tests/projects/misc/SelfDefinedTailCallAttribute/tailcallaltattr.fsproj @@ -7,7 +7,7 @@ - $(MSBuildThisFileDirectory)../../../../artifacts/bin/fsc/Debug/net8.0/fsc.dll + $(MSBuildThisFileDirectory)../../../../artifacts/bin/fsc/Debug/$(FSharpNetCoreProductTargetFramework)/fsc.dll From db6b8cd2630be686101e06b08f17b61e12201fbd Mon Sep 17 00:00:00 2001 From: dawe Date: Fri, 23 Feb 2024 20:00:34 +0100 Subject: [PATCH 19/24] Add a version of TryGetRecentCheckResultsForFile with project snapshot (#16720) * First stab at adding a version of TryGetRecentCheckResultsForFile that takes a snapshot instead of project options * use version type without defaultof<_> = null * take sourcetext out of project snapshot, kind of forces us to an async return but let's see if this is acceptable * format * - reuse ParseAndCheckFileInProject cache for TryGetRecentCheckResultsForFile - extend version of ParseAndCheckFileInProject cache with the check sum of the source code - add test * format * cleanup * use a new LruCache member GetAll to get rid of the dummy version * cleanup * Update src/Compiler/Service/TransparentCompiler.fs Co-authored-by: Petr Pokorny * unify key creation * just use ProjectSnapShot.FileKey * to have it on record, push a version with "f.Version |> Md5Hasher.toString" as the second part of lastFileKey.Version * use FileKeyWithExtraFileSnapshotVersion for the ParseAndCheckFileInProject cache * replace FileSnapShot after edit in Test * add CustomOperation tryGetRecentCheckResults for tests * - Make API non-async and don't return hash - let tests run for background compiler, too * better fix for commandLineOptions order * Update src/Compiler/Service/FSharpProjectSnapshot.fs Co-authored-by: Petr Pokorny * Update tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs Co-authored-by: Petr Pokorny * Update tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs Co-authored-by: Petr Pokorny * fix version predicate * let LruCache.GetAll(key: 'TKey) return a seq instead of a list * compare signatures in CustomOperation tryGetRecentCheckResults to tighten the tests --------- Co-authored-by: Petr Pokorny --- src/Compiler/Facilities/AsyncMemoize.fs | 9 +++ src/Compiler/Facilities/AsyncMemoize.fsi | 2 + src/Compiler/Service/BackgroundCompiler.fs | 22 +++++++ src/Compiler/Service/BackgroundCompiler.fsi | 4 ++ src/Compiler/Service/FSharpProjectSnapshot.fs | 10 +++- src/Compiler/Service/TransparentCompiler.fs | 36 ++++++++++- src/Compiler/Service/TransparentCompiler.fsi | 2 +- src/Compiler/Service/service.fs | 4 ++ src/Compiler/Service/service.fsi | 5 ++ src/Compiler/Utilities/LruCache.fs | 14 +++-- src/Compiler/Utilities/LruCache.fsi | 3 + .../FSharpChecker/TransparentCompiler.fs | 46 +++++++++++++++ ...ervice.SurfaceArea.netstandard20.debug.bsl | 1 + ...vice.SurfaceArea.netstandard20.release.bsl | 1 + .../ProjectGeneration.fs | 30 +++++++++- tests/service/ProjectAnalysisTests.fs | 59 +++++++++++++++++++ 16 files changed, 237 insertions(+), 11 deletions(-) diff --git a/src/Compiler/Facilities/AsyncMemoize.fs b/src/Compiler/Facilities/AsyncMemoize.fs index b780d91ca7..d6ae83ada6 100644 --- a/src/Compiler/Facilities/AsyncMemoize.fs +++ b/src/Compiler/Facilities/AsyncMemoize.fs @@ -534,6 +534,15 @@ type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'T } + member _.TryGet(key: 'TKey, predicate: 'TVersion -> bool) : 'TValue option = + let versionsAndJobs = cache.GetAll(key) + + versionsAndJobs + |> Seq.tryPick (fun (version, job) -> + match predicate version, job with + | true, Completed(completed, _) -> Some completed + | _ -> None) + member _.Clear() = cache.Clear() member _.Clear predicate = cache.Clear predicate diff --git a/src/Compiler/Facilities/AsyncMemoize.fsi b/src/Compiler/Facilities/AsyncMemoize.fsi index a34588e7af..1cce68cf99 100644 --- a/src/Compiler/Facilities/AsyncMemoize.fsi +++ b/src/Compiler/Facilities/AsyncMemoize.fsi @@ -69,6 +69,8 @@ type internal AsyncMemoize<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'T member Get': key: 'TKey * computation: NodeCode<'TValue> -> NodeCode<'TValue> + member TryGet: key: 'TKey * predicate: ('TVersion -> bool) -> 'TValue option + member Event: IEvent member OnEvent: ((JobEvent * (string * 'TKey * 'TVersion) -> unit) -> unit) diff --git a/src/Compiler/Service/BackgroundCompiler.fs b/src/Compiler/Service/BackgroundCompiler.fs index d66847b5c1..d0af1284f1 100644 --- a/src/Compiler/Service/BackgroundCompiler.fs +++ b/src/Compiler/Service/BackgroundCompiler.fs @@ -179,6 +179,10 @@ type internal IBackgroundCompiler = fileName: string * options: FSharpProjectOptions * sourceText: ISourceText option * userOpName: string -> (FSharpParseFileResults * FSharpCheckFileResults * SourceTextHash) option + abstract member TryGetRecentCheckResultsForFile: + fileName: string * projectSnapshot: FSharpProjectSnapshot * userOpName: string -> + (FSharpParseFileResults * FSharpCheckFileResults) option + abstract member BeforeBackgroundFileCheck: IEvent abstract member FileChecked: IEvent @@ -1174,6 +1178,16 @@ type internal BackgroundCompiler | None -> None | None -> None + member _.TryGetRecentCheckResultsForFile(fileName: string, projectSnapshot: FSharpProjectSnapshot, userOpName: string) = + projectSnapshot.ProjectSnapshot.SourceFiles + |> List.tryFind (fun f -> f.FileName = fileName) + |> Option.bind (fun (f: FSharpFileSnapshot) -> + let options = projectSnapshot.ToOptions() + let sourceText = f.GetSource() |> Async.AwaitTask |> Async.RunSynchronously + + self.TryGetRecentCheckResultsForFile(fileName, options, Some sourceText, userOpName) + |> Option.map (fun (parseFileResults, checkFileResults, _hash) -> (parseFileResults, checkFileResults))) + /// Parse and typecheck the whole project (the implementation, called recursively as project graph is evaluated) member private _.ParseAndCheckProjectImpl(options, userOpName) = node { @@ -1732,3 +1746,11 @@ type internal BackgroundCompiler userOpName: string ) : (FSharpParseFileResults * FSharpCheckFileResults * SourceTextHash) option = self.TryGetRecentCheckResultsForFile(fileName, options, sourceText, userOpName) + + member _.TryGetRecentCheckResultsForFile + ( + fileName: string, + projectSnapshot: FSharpProjectSnapshot, + userOpName: string + ) : (FSharpParseFileResults * FSharpCheckFileResults) option = + self.TryGetRecentCheckResultsForFile(fileName, projectSnapshot, userOpName) diff --git a/src/Compiler/Service/BackgroundCompiler.fsi b/src/Compiler/Service/BackgroundCompiler.fsi index cd7c163a0d..fff6324be3 100644 --- a/src/Compiler/Service/BackgroundCompiler.fsi +++ b/src/Compiler/Service/BackgroundCompiler.fsi @@ -169,6 +169,10 @@ type internal IBackgroundCompiler = fileName: string * options: FSharpProjectOptions * sourceText: ISourceText option * userOpName: string -> (FSharpParseFileResults * FSharpCheckFileResults * SourceTextHash) option + abstract TryGetRecentCheckResultsForFile: + fileName: string * projectSnapshot: FSharpProjectSnapshot * userOpName: string -> + (FSharpParseFileResults * FSharpCheckFileResults) option + abstract BeforeBackgroundFileCheck: IEvent abstract FileChecked: IEvent diff --git a/src/Compiler/Service/FSharpProjectSnapshot.fs b/src/Compiler/Service/FSharpProjectSnapshot.fs index 7ab252ef73..76d9705890 100644 --- a/src/Compiler/Service/FSharpProjectSnapshot.fs +++ b/src/Compiler/Service/FSharpProjectSnapshot.fs @@ -345,6 +345,12 @@ type internal ProjectSnapshotBase<'T when 'T :> IFileSnapshot>(projectCore: Proj member this.FileKey(fileName: string) = this.UpTo(fileName).LastFileKey member this.FileKey(index: FileIndex) = this.UpTo(index).LastFileKey + member this.FileKeyWithExtraFileSnapshotVersion(fileName: string) = + let fileKey = this.FileKey fileName + let fileSnapshot = this.SourceFiles |> Seq.find (fun f -> f.FileName = fileName) + + fileKey.WithExtraVersion(fileSnapshot.Version |> Md5Hasher.toString) + /// Project snapshot with filenames and versions given as initial input and internal ProjectSnapshot = ProjectSnapshotBase @@ -394,10 +400,10 @@ and internal ProjectCore let commandLineOptions = lazy (seq { + yield! OtherOptions + for r in ReferencesOnDisk do $"-r:{r.Path}" - - yield! OtherOptions } |> Seq.toList) diff --git a/src/Compiler/Service/TransparentCompiler.fs b/src/Compiler/Service/TransparentCompiler.fs index e85488e773..c5ecfba812 100644 --- a/src/Compiler/Service/TransparentCompiler.fs +++ b/src/Compiler/Service/TransparentCompiler.fs @@ -307,7 +307,7 @@ type internal CompilerCaches(sizeFactor: int) = this.AssemblyData.Clear(shouldClear) this.SemanticClassification.Clear(snd >> shouldClear) this.ItemKeyStore.Clear(snd >> shouldClear) - this.ScriptClosure.Clear(snd >> shouldClear) // Todo check if correct predicate + this.ScriptClosure.Clear(snd >> shouldClear) type internal TransparentCompiler ( @@ -1472,9 +1472,8 @@ type internal TransparentCompiler let ComputeParseAndCheckFileInProject (fileName: string) (projectSnapshot: ProjectSnapshot) = caches.ParseAndCheckFileInProject.Get( - projectSnapshot.FileKey fileName, + projectSnapshot.FileKeyWithExtraFileSnapshotVersion fileName, node { - use _ = Activity.start "ComputeParseAndCheckFileInProject" [| Activity.Tags.fileName, fileName |> Path.GetFileName |] @@ -1605,6 +1604,29 @@ type internal TransparentCompiler } ) + let TryGetRecentCheckResultsForFile + ( + fileName: string, + projectSnapshot: FSharpProjectSnapshot, + userOpName: string + ) : (FSharpParseFileResults * FSharpCheckFileResults) option = + ignore userOpName + + let cacheKey = + projectSnapshot.ProjectSnapshot.FileKeyWithExtraFileSnapshotVersion fileName + + let version = cacheKey.GetVersion() + + let parseFileResultsAndcheckFileAnswer = + caches.ParseAndCheckFileInProject.TryGet( + cacheKey.GetKey(), + (fun (_fullVersion, fileContentVersion) -> fileContentVersion = (snd version)) + ) + + match parseFileResultsAndcheckFileAnswer with + | Some(parseFileResults, FSharpCheckFileAnswer.Succeeded checkFileResults) -> Some(parseFileResults, checkFileResults) + | _ -> None + let ComputeProjectExtras (bootstrapInfo: BootstrapInfo) (projectSnapshot: ProjectSnapshotWithSources) = caches.ProjectExtras.Get( projectSnapshot.SignatureKey, @@ -2356,3 +2378,11 @@ type internal TransparentCompiler userOpName: string ) : (FSharpParseFileResults * FSharpCheckFileResults * SourceTextHash) option = backgroundCompiler.TryGetRecentCheckResultsForFile(fileName, options, sourceText, userOpName) + + member this.TryGetRecentCheckResultsForFile + ( + fileName: string, + projectSnapshot: FSharpProjectSnapshot, + userOpName: string + ) : (FSharpParseFileResults * FSharpCheckFileResults) option = + TryGetRecentCheckResultsForFile(fileName, projectSnapshot, userOpName) diff --git a/src/Compiler/Service/TransparentCompiler.fsi b/src/Compiler/Service/TransparentCompiler.fsi index 9aa5929566..8e581872d8 100644 --- a/src/Compiler/Service/TransparentCompiler.fsi +++ b/src/Compiler/Service/TransparentCompiler.fsi @@ -118,7 +118,7 @@ type internal CompilerCaches = member ParseAndCheckAllFilesInProject: AsyncMemoizeDisabled member ParseAndCheckFileInProject: - AsyncMemoize<(string * (string * string)), string, (FSharpParseFileResults * FSharpCheckFileAnswer)> + AsyncMemoize<(string * (string * string)), string * string, (FSharpParseFileResults * FSharpCheckFileAnswer)> member ParseAndCheckProject: AsyncMemoize<(string * string), string, FSharpCheckProjectResults> diff --git a/src/Compiler/Service/service.fs b/src/Compiler/Service/service.fs index 94dce6286b..103c84e63c 100644 --- a/src/Compiler/Service/service.fs +++ b/src/Compiler/Service/service.fs @@ -338,6 +338,10 @@ type FSharpChecker let userOpName = defaultArg userOpName "Unknown" backgroundCompiler.TryGetRecentCheckResultsForFile(fileName, options, sourceText, userOpName) + member _.TryGetRecentCheckResultsForFile(fileName: string, projectSnapshot: FSharpProjectSnapshot, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.TryGetRecentCheckResultsForFile(fileName, projectSnapshot, userOpName) + member _.Compile(argv: string[], ?userOpName: string) = let _userOpName = defaultArg userOpName "Unknown" use _ = Activity.start "FSharpChecker.Compile" [| Activity.Tags.userOpName, _userOpName |] diff --git a/src/Compiler/Service/service.fsi b/src/Compiler/Service/service.fsi index cb8272b0f6..71e0f51df3 100644 --- a/src/Compiler/Service/service.fsi +++ b/src/Compiler/Service/service.fsi @@ -422,6 +422,11 @@ type public FSharpChecker = fileName: string * options: FSharpProjectOptions * ?sourceText: ISourceText * ?userOpName: string -> (FSharpParseFileResults * FSharpCheckFileResults (* hash *) * int64) option + [] + member TryGetRecentCheckResultsForFile: + fileName: string * projectSnapshot: FSharpProjectSnapshot * ?userOpName: string -> + (FSharpParseFileResults * FSharpCheckFileResults) option + /// This function is called when the entire environment is known to have changed for reasons not encoded in the ProjectOptions of any project/compilation. member InvalidateAll: unit -> unit diff --git a/src/Compiler/Utilities/LruCache.fs b/src/Compiler/Utilities/LruCache.fs index c75ed1d88c..7b06292c2e 100644 --- a/src/Compiler/Utilities/LruCache.fs +++ b/src/Compiler/Utilities/LruCache.fs @@ -198,21 +198,27 @@ type internal LruCache<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'TVers /// Returns an option of a value for given key and version, and also a list of all other versions for given key member this.GetAll(key, version) = - this.TryGet(key, version), + let others = + this.GetAll(key) |> Seq.filter (fun (ver, _val) -> ver <> version) |> Seq.toList + this.TryGet(key, version), others + + /// Returns a list of version * value pairs for a given key. The strongly held value is first in the list. + member _.GetAll(key: 'TKey) : ('TVersion * 'TValue) seq = match dictionary.TryGetValue key with | false, _ -> [] | true, versionDict -> versionDict.Values - |> Seq.map (fun node -> node.Value) - |> Seq.filter (p24 >> ((<>) version)) + |> Seq.map (_.Value) + |> Seq.sortBy (function + | _, _, _, Strong _ -> 0 + | _ -> 1) |> Seq.choose (function | _, ver, _, Strong v -> Some(ver, v) | _, ver, _, Weak r -> match r.TryGetTarget() with | true, x -> Some(ver, x) | _ -> None) - |> Seq.toList member _.Remove(key, version) = match dictionary.TryGetValue key with diff --git a/src/Compiler/Utilities/LruCache.fsi b/src/Compiler/Utilities/LruCache.fsi index d9aefd2a24..eb2880047d 100644 --- a/src/Compiler/Utilities/LruCache.fsi +++ b/src/Compiler/Utilities/LruCache.fsi @@ -33,6 +33,9 @@ type internal LruCache<'TKey, 'TVersion, 'TValue when 'TKey: equality and 'TVers /// Returns an option of a value for given key and version, and also a list of all other versions for given key member GetAll: key: 'TKey * version: 'TVersion -> 'TValue option * ('TVersion * 'TValue) list + /// Returns a list of version * value pairs for a given key. The strongly held value is first in the list. + member GetAll: key: 'TKey -> ('TVersion * 'TValue) seq + member GetValues: unit -> (string * 'TVersion * 'TValue) seq member Remove: key: 'TKey -> unit diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs index 2adb305a2e..0b6daf9606 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs @@ -896,6 +896,52 @@ let ``LoadClosure for script is recomputed after changes`` () = |> Map Assert.Equal([Weakened; Requested; Started; Finished; Weakened; Requested; Started; Finished], closureComputations["FileFirst.fs"]) + +[] +let ``TryGetRecentCheckResultsForFile returns None before first call to ParseAndCheckFileInProject`` () = + let project = SyntheticProject.Create( + sourceFile "First" []) + + ProjectWorkflowBuilder(project) { + clearCache + tryGetRecentCheckResults "First" expectNone + } |> ignore + +[] +let ``TryGetRecentCheckResultsForFile returns result after first call to ParseAndCheckFileInProject`` () = + let project = SyntheticProject.Create( + sourceFile "First" [] ) + + ProjectWorkflowBuilder(project) { + tryGetRecentCheckResults "First" expectSome + } |> ignore + +[] +let ``TryGetRecentCheckResultsForFile returns no result after edit`` () = + let project = SyntheticProject.Create( + sourceFile "First" []) + + ProjectWorkflowBuilder(project) { + tryGetRecentCheckResults "First" expectSome + updateFile "First" updatePublicSurface + tryGetRecentCheckResults "First" expectNone + checkFile "First" expectOk + tryGetRecentCheckResults "First" expectSome + } |> ignore + +[] +let ``TryGetRecentCheckResultsForFile returns result after edit of other file`` () = + let project = SyntheticProject.Create( + sourceFile "First" [], + sourceFile "Second" ["First"]) + + ProjectWorkflowBuilder(project) { + tryGetRecentCheckResults "First" expectSome + tryGetRecentCheckResults "Second" expectSome + updateFile "First" updatePublicSurface + tryGetRecentCheckResults "First" expectNone + tryGetRecentCheckResults "Second" expectSome // file didn't change so we still want to get the recent result + } |> ignore [] let ``Background compiler and Transparent compiler return the same options`` () = 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 69fb762ea8..3c4b22f76c 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 @@ -2079,6 +2079,7 @@ FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.IEvent`2[Mi FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.IEvent`2[Microsoft.FSharp.Control.FSharpHandler`1[System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]],System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]] get_BeforeBackgroundFileCheck() FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.IEvent`2[Microsoft.FSharp.Control.FSharpHandler`1[System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]],System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]] get_FileChecked() FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.IEvent`2[Microsoft.FSharp.Control.FSharpHandler`1[System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]],System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]] get_FileParsed() +FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpParseFileResults,FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults]] TryGetRecentCheckResultsForFile(System.String, FSharpProjectSnapshot, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[FSharp.Compiler.CodeAnalysis.FSharpParseFileResults,FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults,System.Int64]] TryGetRecentCheckResultsForFile(System.String, FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.ISourceText], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpParsingOptions,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Diagnostics.FSharpDiagnostic]] GetParsingOptionsFromCommandLineArgs(Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) FSharp.Compiler.CodeAnalysis.FSharpChecker: System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpParsingOptions,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Diagnostics.FSharpDiagnostic]] GetParsingOptionsFromCommandLineArgs(Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) 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 69fb762ea8..3c4b22f76c 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 @@ -2079,6 +2079,7 @@ FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.IEvent`2[Mi FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.IEvent`2[Microsoft.FSharp.Control.FSharpHandler`1[System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]],System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]] get_BeforeBackgroundFileCheck() FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.IEvent`2[Microsoft.FSharp.Control.FSharpHandler`1[System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]],System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]] get_FileChecked() FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Control.IEvent`2[Microsoft.FSharp.Control.FSharpHandler`1[System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]],System.Tuple`2[System.String,FSharp.Compiler.CodeAnalysis.FSharpProjectOptions]] get_FileParsed() +FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpParseFileResults,FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults]] TryGetRecentCheckResultsForFile(System.String, FSharpProjectSnapshot, Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: Microsoft.FSharp.Core.FSharpOption`1[System.Tuple`3[FSharp.Compiler.CodeAnalysis.FSharpParseFileResults,FSharp.Compiler.CodeAnalysis.FSharpCheckFileResults,System.Int64]] TryGetRecentCheckResultsForFile(System.String, FSharp.Compiler.CodeAnalysis.FSharpProjectOptions, Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.ISourceText], Microsoft.FSharp.Core.FSharpOption`1[System.String]) FSharp.Compiler.CodeAnalysis.FSharpChecker: System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpParsingOptions,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Diagnostics.FSharpDiagnostic]] GetParsingOptionsFromCommandLineArgs(Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) FSharp.Compiler.CodeAnalysis.FSharpChecker: System.Tuple`2[FSharp.Compiler.CodeAnalysis.FSharpParsingOptions,Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Diagnostics.FSharpDiagnostic]] GetParsingOptionsFromCommandLineArgs(Microsoft.FSharp.Collections.FSharpList`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean]) diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index 2157d8fb7f..998f2bd201 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -754,7 +754,13 @@ module ProjectOperations = |> Seq.toArray Assert.Equal<(string * int * int * int)[]>(expected |> Seq.sort |> Seq.toArray, actual) - + + let expectNone x = + if Option.isSome x then failwith "expected None, but was Some" + + let expectSome x = + if Option.isNone x then failwith "expected Some, but was None" + let rec saveProject (p: SyntheticProject) generateSignatureFiles checker = async { Directory.CreateDirectory(p.ProjectDir) |> ignore @@ -1346,6 +1352,28 @@ type ProjectWorkflowBuilder exn $"Compilation failed with exit code {exitCode}" |> raise return ctx } + + [] + member this.TryGetRecentCheckResults(workflow: Async, fileId: string, expected) = + async { + let! ctx = workflow + let project, file = ctx.Project.FindInAllProjects fileId + let fileName = project.ProjectDir ++ file.FileName + let options = project.GetProjectOptions checker + let! snapshot = FSharpProjectSnapshot.FromOptions(options, getFileSnapshot ctx.Project) + let r = checker.TryGetRecentCheckResultsForFile(fileName, snapshot) + expected r + + match r with + | Some(parseFileResults, checkFileResults) -> + let signature = getSignature(parseFileResults, FSharpCheckFileAnswer.Succeeded(checkFileResults)) + match ctx.Signatures.TryFind(fileId) with + | Some priorSignature -> Assert.Equal(priorSignature, signature) + | None -> () + | None -> () + + return ctx + } /// Execute a set of operations on a given synthetic project. /// The project is saved to disk and type checked at the start. diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 266ec0d900..0336edf78b 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -5462,6 +5462,65 @@ type A(i:int) = | Some decl -> failwithf "unexpected declaration %A" decl | None -> failwith "declaration list is empty" +[] +[] +[] +let ``TryGetRecentCheckResultsForFile called with snapshot returns cached result after ParseAndCheckFile`` useTransparentCompiler = + let fileName1 = Path.ChangeExtension(tryCreateTemporaryFileName (), ".fs") + let base2 = tryCreateTemporaryFileName () + let dllName = Path.ChangeExtension(base2, ".dll") + let projFileName = Path.ChangeExtension(base2, ".fsproj") + let fileSource1Text = """ +type A(i:int) = + member x.Value = i +""" + let fileSource1 = SourceText.ofString fileSource1Text + FileSystem.OpenFileForWriteShim(fileName1).Write(fileSource1Text) + + let fileNames = [|fileName1|] + let args = mkProjectCommandLineArgs (dllName, []) + let checker = FSharpChecker.Create(useTransparentCompiler=useTransparentCompiler) + let options = { checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) with SourceFiles = fileNames } + let snapshot = FSharpProjectSnapshot.FromOptions(options, DocumentSource.FileSystem) |> Async.RunImmediate + + let rbefore = checker.TryGetRecentCheckResultsForFile(fileName1, snapshot) + match rbefore with + | Some(fileResults, checkFileResults) -> failwith "cached results before ParseAndCheckFileInProject was called" + | None -> () + + checker.ParseAndCheckFileInProject(fileName1, snapshot) |> Async.RunImmediate + |> function + | _, FSharpCheckFileAnswer.Succeeded(res) -> () + | _ -> failwithf "Parsing aborted unexpectedly..." + + let rafterCheckResults = checker.TryGetRecentCheckResultsForFile(fileName1, snapshot) + match rafterCheckResults with + | Some(fileResults, checkFileResults) -> () + | None -> failwith "no results from TryGetRecentCheckResultsForFile" + + let fileSource1TextEdited = """ +type A(i:int) = + member x.Value = i + member x.Value2 = 23 +""" + let fileSource1Edited = SourceText.ofString fileSource1TextEdited + FileSystem.OpenFileForWriteShim(fileName1).Write(fileSource1TextEdited) + let snapshotAfterFileEdit = FSharpProjectSnapshot.FromOptions(options, DocumentSource.FileSystem) |> Async.RunImmediate + + let rafterEditBefore2ndCheckResults = checker.TryGetRecentCheckResultsForFile(fileName1, snapshotAfterFileEdit) + match rafterEditBefore2ndCheckResults with + | Some(fileResults, checkFileResults) -> failwith "stale cache results from TryGetRecentCheckResultsForFile after edit" + | None -> () + + checker.ParseAndCheckFileInProject(fileName1, snapshotAfterFileEdit) |> Async.RunImmediate + |> function + | _, FSharpCheckFileAnswer.Succeeded(res) -> () + | _ -> failwithf "Parsing aborted unexpectedly..." + + let rafterEditAfter2ndCheckResults = checker.TryGetRecentCheckResultsForFile(fileName1, snapshotAfterFileEdit) + match rafterEditAfter2ndCheckResults with + | Some(fileResults, checkFileResults) -> () + | None -> failwith "no results from TryGetRecentCheckResultsForFile" [] [] From 86d05ef443a41bdccf6e76915a2cb18cd7a9eb8b Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Sat, 24 Feb 2024 20:15:34 +0100 Subject: [PATCH 20/24] Prefixed module nameof (#16743) (#16747) --- .../.FSharp.Compiler.Service/8.0.202.md | 2 +- .../GraphChecking/FileContentMapping.fs | 41 ++++++++++++++++--- .../TypeChecks/Graph/Scenarios.fs | 31 ++++++++++++++ 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.202.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.202.md index a34e8e6442..0780d447b5 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.202.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.202.md @@ -1,3 +1,3 @@ ### Fixed -* `nameof Module` expressions and patterns are processed to link files in `--test:GraphBasedChecking`. ([PR #16570](https://github.com/dotnet/fsharp/pull/16570)) +`nameof Module` expressions and patterns are processed to link files in `--test:GraphBasedChecking`. ([PR #16570](https://github.com/dotnet/fsharp/pull/16570), [PR #16747](https://github.com/dotnet/fsharp/pull/16747)) diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index f86298308a..2bd9e73092 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -311,8 +311,27 @@ let visitSynTypeConstraint (tc: SynTypeConstraint) : FileContentEntry list = let inline (|NameofIdent|_|) (ident: Ident) = if ident.idText = "nameof" then ValueSome() else ValueNone +/// nameof X.Y.Z can be used in expressions and patterns +[] +type NameofResult = + /// Example: nameof X + /// Where X is a module name + | SingleIdent of potentialModuleName: Ident + /// Example: nameof X.Y.Z + /// Where Z is either a module name or something from inside module or namespace Y. + /// Both options need to be explored. + | LongIdent of longIdent: LongIdent + +let visitNameofResult (nameofResult: NameofResult) : FileContentEntry = + match nameofResult with + | NameofResult.SingleIdent moduleName -> visitIdentAsPotentialModuleName moduleName + | NameofResult.LongIdent longIdent -> + // In this case the last part of the LongIdent could be a module name. + // So we should not cut off the last part. + FileContentEntry.PrefixedIdentifier(longIdentToPath false longIdent) + /// Special case of `nameof Module` type of expression -let (|NameofExpr|_|) (e: SynExpr) = +let (|NameofExpr|_|) (e: SynExpr) : NameofResult option = let rec stripParen (e: SynExpr) = match e with | SynExpr.Paren(expr = expr) -> stripParen expr @@ -321,14 +340,20 @@ let (|NameofExpr|_|) (e: SynExpr) = match e with | SynExpr.App(flag = ExprAtomicFlag.NonAtomic; isInfix = false; funcExpr = SynExpr.Ident NameofIdent; argExpr = moduleNameExpr) -> match stripParen moduleNameExpr with - | SynExpr.Ident moduleNameIdent -> Some moduleNameIdent + | SynExpr.Ident moduleNameIdent -> Some(NameofResult.SingleIdent moduleNameIdent) + | SynExpr.LongIdent(longDotId = longIdent) -> + match longIdent.LongIdent with + | [] -> None + // This is highly unlikely to be produced by the parser + | [ moduleNameIdent ] -> Some(NameofResult.SingleIdent moduleNameIdent) + | lid -> Some(NameofResult.LongIdent(lid)) | _ -> None | _ -> None let visitSynExpr (e: SynExpr) : FileContentEntry list = let rec visit (e: SynExpr) (continuation: FileContentEntry list -> FileContentEntry list) : FileContentEntry list = match e with - | NameofExpr moduleNameIdent -> continuation [ visitIdentAsPotentialModuleName moduleNameIdent ] + | NameofExpr nameofResult -> continuation [ visitNameofResult nameofResult ] | SynExpr.Const _ -> continuation [] | SynExpr.Paren(expr = expr) -> visit expr continuation | SynExpr.Quote(operator = operator; quotedExpr = quotedExpr) -> @@ -552,18 +577,22 @@ let (|NameofPat|_|) (pat: SynPat) = | SynPat.LongIdent(longDotId = SynLongIdent(id = [ NameofIdent ]); typarDecls = None; argPats = SynArgPats.Pats [ moduleNamePat ]) -> match stripPats moduleNamePat with | SynPat.LongIdent( - longDotId = SynLongIdent.SynLongIdent(id = [ moduleNameIdent ]; dotRanges = []; trivia = [ None ]) + longDotId = SynLongIdent.SynLongIdent(id = longIdent) extraId = None typarDecls = None argPats = SynArgPats.Pats [] - accessibility = None) -> Some moduleNameIdent + accessibility = None) -> + match longIdent with + | [] -> None + | [ moduleNameIdent ] -> Some(NameofResult.SingleIdent moduleNameIdent) + | lid -> Some(NameofResult.LongIdent lid) | _ -> None | _ -> None let visitPat (p: SynPat) : FileContentEntry list = let rec visit (p: SynPat) (continuation: FileContentEntry list -> FileContentEntry list) : FileContentEntry list = match p with - | NameofPat moduleNameIdent -> continuation [ visitIdentAsPotentialModuleName moduleNameIdent ] + | NameofPat moduleNameIdent -> continuation [ visitNameofResult moduleNameIdent ] | SynPat.Paren(pat = pat) -> visit pat continuation | SynPat.Typed(pat = pat; targetType = t) -> visit pat (fun nodes -> nodes @ visitSynType t) | SynPat.Const _ -> continuation [] diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs index 80f7caecaf..524556dae0 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/Scenarios.fs @@ -796,6 +796,8 @@ type Foo = class end sourceFile "Program" """ +module Program + printfn "Hello" """ Set.empty @@ -907,6 +909,35 @@ do module Bar let _ = nameof ((Foo)) +""" + (set [| 0 |]) + ] + scenario + "prefixed module name in nameof expression" + [ + sourceFile "A.fs" "module X.Y.Z" Set.empty + sourceFile + "B.fs" + """ +module B + +open System.ComponentModel + +[] +let v = 2 +""" + (set [| 0 |]) + ] + scenario + "prefixed module name in nameof pattern" + [ + sourceFile "A.fs" "module X.Y.Z" Set.empty + sourceFile + "B.fs" + """ +module B + +do ignore (match "" with | nameof X.Y.Z -> () | _ -> ()) """ (set [| 0 |]) ] From 1816538b7f664d36c673e1fe6f6b36bb6d06aa64 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 26 Feb 2024 11:18:40 +0000 Subject: [PATCH 21/24] Enforce attribute targets on functions (#16692) --- .../.FSharp.Compiler.Service/8.0.300.md | 1 + docs/release-notes/.Language/preview.md | 3 +- src/Compiler/Checking/CheckExpressions.fs | 13 +- src/Compiler/Checking/TailCallChecks.fs | 7 +- src/Compiler/FSComp.txt | 1 + src/Compiler/Facilities/LanguageFeatures.fs | 3 + src/Compiler/Facilities/LanguageFeatures.fsi | 1 + src/Compiler/xlf/FSComp.txt.cs.xlf | 5 + src/Compiler/xlf/FSComp.txt.de.xlf | 5 + src/Compiler/xlf/FSComp.txt.es.xlf | 5 + src/Compiler/xlf/FSComp.txt.fr.xlf | 5 + src/Compiler/xlf/FSComp.txt.it.xlf | 5 + src/Compiler/xlf/FSComp.txt.ja.xlf | 5 + src/Compiler/xlf/FSComp.txt.ko.xlf | 5 + src/Compiler/xlf/FSComp.txt.pl.xlf | 5 + src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 + src/Compiler/xlf/FSComp.txt.ru.xlf | 5 + src/Compiler/xlf/FSComp.txt.tr.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 + .../AttributeUsage/AttributeUsage.fs | 141 ++++++++++++++++++ .../E_AttributeTargetIsField01.fs | 67 +++++++++ .../E_AttributeTargetIsField02.fs | 69 +++++++++ .../E_AttributeTargetIsMethod02.fs | 40 +++++ .../E_AttributeTargetIsMethod03.fs | 54 +++++++ .../ErrorMessages/TailCallAttribute.fs | 24 +-- tests/service/ProjectAnalysisTests.fs | 12 +- 27 files changed, 466 insertions(+), 35 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsField01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsField02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod03.fs 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 80d327e5d9..786a741dbf 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.300.md @@ -11,6 +11,7 @@ * `[]` member should not produce property symbol. ([Issue #16640](https://github.com/dotnet/fsharp/issues/16640), [PR #16658](https://github.com/dotnet/fsharp/pull/16658)) * Fix discriminated union initialization. ([#PR 16661](https://github.com/dotnet/fsharp/pull/16661)) * Allow calling method with both Optional and ParamArray. ([#PR 16688](https://github.com/dotnet/fsharp/pull/16688), [suggestions #1120](https://github.com/fsharp/fslang-suggestions/issues/1120)) +* Enforce AttributeTargets on let values and functions. ([PR #16692](https://github.com/dotnet/fsharp/pull/16692)) ### Added diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index d1880b4dd8..f39dd17256 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -8,7 +8,8 @@ ### Fixed * Allow extension methods without type attribute work for types from imported assemblies. ([PR #16368](https://github.com/dotnet/fsharp/pull/16368)) +* Enforce AttributeTargets on let values and functions. ([PR #16692](https://github.com/dotnet/fsharp/pull/16692)) ### Changed -* Lower interpolated strings to string concatenation. ([PR #16556](https://github.com/dotnet/fsharp/pull/16556)) \ No newline at end of file +* Lower interpolated strings to string concatenation. ([PR #16556](https://github.com/dotnet/fsharp/pull/16556)) diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 89268e1ee6..3e3e90a72f 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -10636,8 +10636,7 @@ and TcNormalizedBinding declKind (cenv: cenv) env tpenv overallTy safeThisValOpt | ModuleOrMemberBinding, SynBindingKind.StandaloneExpression, _ -> Some(".cctor") | _, _, _ -> envinner.eCallerMemberName - let envinner = {envinner with eCallerMemberName = callerName } - + let envinner = { envinner with eCallerMemberName = callerName } let attrTgt = declKind.AllowedAttribTargets memberFlagsOpt let isFixed, rhsExpr, overallPatTy, overallExprTy = @@ -10873,6 +10872,16 @@ and TcNormalizedBinding declKind (cenv: cenv) env tpenv overallTy safeThisValOpt errorR(Error(FSComp.SR.tcLiteralCannotBeInline(), mBinding)) if not (isNil declaredTypars) then errorR(Error(FSComp.SR.tcLiteralCannotHaveGenericParameters(), mBinding)) + + if g.langVersion.SupportsFeature(LanguageFeature.EnforceAttributeTargetsOnFunctions) && memberFlagsOpt.IsNone && not attrs.IsEmpty then + let rhsIsFunction = isFunTy g overallPatTy + let lhsIsFunction = isFunTy g overallExprTy + let attrTgt = + match rhsIsFunction, lhsIsFunction with + | false, false when declaredTypars.IsEmpty -> AttributeTargets.Field ||| AttributeTargets.Property ||| AttributeTargets.ReturnValue + | _, _ -> AttributeTargets.Method ||| AttributeTargets.ReturnValue + + TcAttributesWithPossibleTargets false cenv env attrTgt attrs |> ignore CheckedBindingInfo(inlineFlag, valAttribs, xmlDoc, tcPatPhase2, explicitTyparInfo, nameToPrelimValSchemeMap, rhsExprChecked, argAndRetAttribs, overallPatTy, mBinding, debugPoint, isCompGen, literalValue, isFixed), tpenv diff --git a/src/Compiler/Checking/TailCallChecks.fs b/src/Compiler/Checking/TailCallChecks.fs index c26683e3da..ce6ab702bd 100644 --- a/src/Compiler/Checking/TailCallChecks.fs +++ b/src/Compiler/Checking/TailCallChecks.fs @@ -725,12 +725,7 @@ let CheckModuleBinding cenv (isRec: bool) (TBind _ as bind) = // warn for non-rec functions which have the attribute if cenv.g.langVersion.SupportsFeature LanguageFeature.WarningWhenTailCallAttrOnNonRec then - let isNotAFunction = - match bind.Var.ValReprInfo with - | Some info -> info.HasNoArgs - | _ -> false - - if (not isRec || isNotAFunction) && cenv.g.HasTailCallAttrib bind.Var.Attribs then + if not isRec && cenv.g.HasTailCallAttrib bind.Var.Attribs then warning (Error(FSComp.SR.chkTailCallAttrOnNonRec (), bind.Var.Range)) // Check if a let binding to the result of a rec expression is not inside the rec expression diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 1fef46084d..a1086629fb 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1594,6 +1594,7 @@ featureWarningIndexedPropertiesGetSetSameType,"Indexed properties getter and set featureChkTailCallAttrOnNonRec,"Raises warnings if the 'TailCall' attribute is used on non-recursive functions." featureUnionIsPropertiesVisible,"Union case test properties" featureBooleanReturningAndReturnTypeDirectedPartialActivePattern,"Boolean-returning and return-type-directed partial active patterns" +featureEnforceAttributeTargetsOnFunctions,"Enforce AttributeTargets on functions" featureLowerInterpolatedStringToConcat,"Optimizes interpolated strings in certain cases, by lowering to concatenation" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 66547a12e2..6e2d91bc6c 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -85,6 +85,7 @@ type LanguageFeature = | WarningIndexedPropertiesGetSetSameType | WarningWhenTailCallAttrOnNonRec | BooleanReturningAndReturnTypeDirectedPartialActivePattern + | EnforceAttributeTargetsOnFunctions | LowerInterpolatedStringToConcat /// LanguageVersion management @@ -198,6 +199,7 @@ type LanguageVersion(versionText) = LanguageFeature.WarningWhenTailCallAttrOnNonRec, previewVersion LanguageFeature.UnionIsPropertiesVisible, previewVersion LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern, previewVersion + LanguageFeature.EnforceAttributeTargetsOnFunctions, previewVersion LanguageFeature.LowerInterpolatedStringToConcat, previewVersion ] @@ -342,6 +344,7 @@ type LanguageVersion(versionText) = | LanguageFeature.WarningWhenTailCallAttrOnNonRec -> FSComp.SR.featureChkTailCallAttrOnNonRec () | LanguageFeature.BooleanReturningAndReturnTypeDirectedPartialActivePattern -> FSComp.SR.featureBooleanReturningAndReturnTypeDirectedPartialActivePattern () + | LanguageFeature.EnforceAttributeTargetsOnFunctions -> FSComp.SR.featureEnforceAttributeTargetsOnFunctions () | LanguageFeature.LowerInterpolatedStringToConcat -> FSComp.SR.featureLowerInterpolatedStringToConcat () /// Get a version string associated with the given feature. diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 582c191ac8..4888479d86 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -76,6 +76,7 @@ type LanguageFeature = | WarningIndexedPropertiesGetSetSameType | WarningWhenTailCallAttrOnNonRec | BooleanReturningAndReturnTypeDirectedPartialActivePattern + | EnforceAttributeTargetsOnFunctions | LowerInterpolatedStringToConcat /// LanguageVersion management diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 27098c6bd1..d4142d783f 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -292,6 +292,11 @@ literál float32 bez tečky + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides Vyvolá chyby pro přepsání jiných než virtuálních členů diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index c89e0988f8..fa0904ef50 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -292,6 +292,11 @@ punktloses float32-Literal + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides Löst Fehler für Außerkraftsetzungen nicht virtueller Member aus. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index de54c17c1f..2d5ada6357 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -292,6 +292,11 @@ literal float32 sin punto + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides Genera errores para invalidaciones de miembros no virtuales diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 1780752360..da3c6f4b9b 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -292,6 +292,11 @@ littéral float32 sans point + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides Déclenche des erreurs pour les remplacements de membres non virtuels diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index 1661484a63..010e34a81a 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -292,6 +292,11 @@ valore letterale float32 senza punti + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides Genera errori per gli override dei membri non virtuali diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index a5a04b7c1b..8a92ac2ea9 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -292,6 +292,11 @@ ドットなしの float32 リテラル + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides 仮想メンバー以外のオーバーライドに対してエラーを発生させます diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index d419bd0d99..51778bd414 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -292,6 +292,11 @@ 점이 없는 float32 리터럴 + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides 비가상 멤버 재정의에 대한 오류 발생 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 65d582f379..a8a3f05ba9 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -292,6 +292,11 @@ bezkropkowy literał float32 + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides Zgłasza błędy w przypadku przesłonięć elementów innych niż wirtualne diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 93af3d22e7..1f62f9a3d0 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -292,6 +292,11 @@ literal float32 sem ponto + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides Gera erros para substituições de membros não virtuais diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index b13f061163..64ce92b612 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -292,6 +292,11 @@ литерал float32 без точки + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides Вызывает ошибки при переопределениях невиртуальных элементов diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index ad43bfe169..d77dfd672e 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -292,6 +292,11 @@ noktasız float32 sabit değeri + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides Sanal olmayan üyelerde geçersiz kılmalar için hatalar oluştur diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index d7013ad94e..5393d25202 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -292,6 +292,11 @@ 无点 float32 文本 + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides 引发非虚拟成员替代的错误 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 902612c1b6..f75fc155fd 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -292,6 +292,11 @@ 無點號的 float32 常值 + + Enforce AttributeTargets on functions + Enforce AttributeTargets on functions + + Raises errors for non-virtual members overrides 引發非虛擬成員覆寫的錯誤 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs index cddee9f80a..c7861ee3e5 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs @@ -94,6 +94,147 @@ module CustomAttributes_AttributeUsage = (Error 842, Line 24, Col 7, Line 24, Col 36, "This attribute is not valid for use on this language element") (Error 842, Line 29, Col 15, Line 29, Col 47, "This attribute is not valid for use on this language element") ] + + // SOURCE=E_AttributeTargetIsField01.fs # E_AttributeTargetIsField01.fs + [] + let ``E_AttributeTargetIsField01_fs`` compilation = + compilation + |> withLangVersion80 + |> withOptions ["--nowarn:25"] + |> verifyCompile + |> shouldSucceed + + // SOURCE=E_AttributeTargetIsField01.fs # E_AttributeTargetIsField01.fs + [] + let ``E_AttributeTargetIsField01_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> withOptions ["--nowarn:25"] + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 842, Line 9, Col 3, Line 9, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 12, Col 3, Line 12, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 15, Col 3, Line 15, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 18, Col 3, Line 18, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 21, Col 3, Line 21, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 24, Col 3, Line 24, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 27, Col 3, Line 27, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 30, Col 3, Line 30, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 33, Col 3, Line 33, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 36, Col 3, Line 36, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 39, Col 3, Line 39, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 42, Col 3, Line 42, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 45, Col 3, Line 45, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 49, Col 3, Line 49, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 56, Col 3, Line 56, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 64, Col 3, Line 64, Col 12, "This attribute is not valid for use on this language element") + (Error 842, Line 66, Col 7, Line 66, Col 16, "This attribute is not valid for use on this language element") + ] + + // SOURCE=E_AttributeTargetIsField02.fs # E_AttributeTargetIsField02.fs + [] + let ``E_AttributeTargetIsField02_fs`` compilation = + compilation + |> withLangVersion80 + |> withOptions ["--nowarn:25"] + |> verifyCompile + |> shouldSucceed + + // SOURCE=E_AttributeTargetIsField02.fs # E_AttributeTargetIsField02.fs + [] + let ``E_AttributeTargetIsField02_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> withOptions ["--nowarn:25"] + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 842, Line 11, Col 6, Line 11, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 14, Col 6, Line 14, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 17, Col 6, Line 17, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 19, Col 10, Line 19, Col 19, "This attribute is not valid for use on this language element") + (Error 842, Line 21, Col 6, Line 21, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 24, Col 6, Line 24, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 27, Col 6, Line 27, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 30, Col 6, Line 30, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 33, Col 6, Line 33, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 36, Col 6, Line 36, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 39, Col 6, Line 39, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 42, Col 6, Line 42, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 45, Col 6, Line 45, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 49, Col 6, Line 49, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 56, Col 6, Line 56, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 64, Col 6, Line 64, Col 15, "This attribute is not valid for use on this language element") + (Error 842, Line 66, Col 10, Line 66, Col 19, "This attribute is not valid for use on this language element") + (Error 842, Line 68, Col 6, Line 68, Col 15, "This attribute is not valid for use on this language element") + ] + + // SOURCE=E_AttributeTargetIsMethod02.fs # E_AttributeTargetIsMethod02.fs + [] + let ``E_AttributeTargetIsMethod02_fs`` compilation = + compilation + |> withLangVersion80 + |> withOptions ["--nowarn:25"] + |> verifyCompile + |> shouldSucceed + + // SOURCE=E_AttributeTargetIsMethod02.fs # E_AttributeTargetIsMethod02.fs + [] + let ``E_AttributeTargetIsMethod02_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> withOptions ["--nowarn:25"] + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 842, Line 9, Col 3, Line 9, Col 13, "This attribute is not valid for use on this language element") + (Error 842, Line 12, Col 3, Line 12, Col 13, "This attribute is not valid for use on this language element") + (Error 842, Line 15, Col 3, Line 15, Col 13, "This attribute is not valid for use on this language element") + (Error 842, Line 18, Col 3, Line 18, Col 13, "This attribute is not valid for use on this language element") + (Error 842, Line 21, Col 3, Line 21, Col 13, "This attribute is not valid for use on this language element") + (Error 842, Line 24, Col 3, Line 24, Col 13, "This attribute is not valid for use on this language element") + (Error 842, Line 26, Col 7, Line 26, Col 17, "This attribute is not valid for use on this language element") + (Error 842, Line 28, Col 3, Line 28, Col 13, "This attribute is not valid for use on this language element") + (Error 842, Line 31, Col 3, Line 31, Col 13, "This attribute is not valid for use on this language element") + (Error 842, Line 34, Col 3, Line 34, Col 13, "This attribute is not valid for use on this language element") + (Error 842, Line 39, Col 3, Line 39, Col 13, "This attribute is not valid for use on this language element") + ] + + // SOURCE=E_AttributeTargetIsMethod03.fs # E_AttributeTargetIsMethod03.fs + [] + let ``E_AttributeTargetIsMethod03_fs`` compilation = + compilation + |> withLangVersion80 + |> withOptions ["--nowarn:25"] + |> verifyCompile + |> shouldSucceed + + // SOURCE=E_AttributeTargetIsMethod03.fs # E_AttributeTargetIsMethod03.fs + [] + let ``E_AttributeTargetIsMethod03_fs preview`` compilation = + compilation + |> withLangVersionPreview + |> withOptions ["--nowarn:25"] + |> verifyCompile + |> shouldFail + |> withDiagnostics [ + (Error 842, Line 12, Col 6, Line 12, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 15, Col 6, Line 15, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 18, Col 6, Line 18, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 20, Col 10, Line 20, Col 20, "This attribute is not valid for use on this language element") + (Error 842, Line 22, Col 6, Line 22, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 25, Col 6, Line 25, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 28, Col 6, Line 28, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 31, Col 6, Line 31, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 34, Col 6, Line 34, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 37, Col 6, Line 37, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 39, Col 10, Line 39, Col 20, "This attribute is not valid for use on this language element") + (Error 842, Line 41, Col 6, Line 41, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 44, Col 6, Line 44, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 47, Col 6, Line 47, Col 16, "This attribute is not valid for use on this language element") + (Error 842, Line 52, Col 6, Line 52, Col 16, "This attribute is not valid for use on this language element") + ] // SOURCE=E_ConditionalAttribute.fs SCFLAGS="--test:ErrorRanges" # E_ConditionalAttribute.fs [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsField01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsField01.fs new file mode 100644 index 0000000000..1e3e48516c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsField01.fs @@ -0,0 +1,67 @@ +// This tests that AttributeTargets.Field is not allowed in let function bindings + +open System + +[] +type FieldOnlyAttribute() = + inherit Attribute() + +[] // Should fail +let func1 () = "someFunction" + +[] // Should fail +let func2 a = a + 1 + +[] // Should fail +let func3 (a, b) = a + b + +[] // Should fail +let func4 (a: int) : int = a + 1 + +[] // Should fail +let func5 a b = [ a; b ] + +[] // Should fail +let func6<'a> = "someTypedFunction" + +[] // Should fail +let func7<'a> (x : 'a) = "someTypedFunction2" + +[] // Should fail +let func8 = fun x -> x + +[] // Should fail +let func9 = id + +[] // Should fail +let __func10<'a> = false + +[] // Should fail +let __func11<'a> : bool = false + +[] // Should fail +let (|Bool|_|) = function "true" -> Some true | "false" -> Some false | _ -> None + +[] // Should fail +[] +let (|BoolExpr2|_|) = function "true" -> ValueSome true | "false" -> ValueSome false | _ -> ValueNone + +[] // Should fail +let (|BoolExpr3|_|) x = + match x with + | "true" -> Some true + | "false" -> Some false + | _ -> None + +[] // Should fail +[] +let (|BoolExpr4|_|) x = + match x with + | "true" -> ValueSome true + | "false" -> ValueSome false + | _ -> ValueNone + +[] // Should fail +let rec func12() = 0 +and [] func13() = [] // Should fail + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsField02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsField02.fs new file mode 100644 index 0000000000..c7ba6dda24 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsField02.fs @@ -0,0 +1,69 @@ +// This tests that AttributeTargets.Field is not allowed in class let function bindings + +open System +open System.Diagnostics + +[] +type FieldOnlyAttribute() = + inherit Attribute() + +type TestClass() = + [] // Should fail + static let func1() = "someFunction" + + [] // Should fail + static let rec func2() = "someFunction" + + []// Should fail + static let rec func3() = "someFunction" + and [] fun4() = "someFunction" // Should fail + + [] // Should fail + let func5 () = "someFunction" + + [] // Should fail + let func6 a = a + 1 + + [] // Should fail + let func7 (a, b) = a + b + + [] // Should fail + let func8 (a: int) : int = a + 1 + + [] // Should fail + let func9 a b = [ a; b ] + + [] // Should fail + let func10 = fun x -> x + + [] // Should fail + let func11 = id + + [] // Should fail + let (|Bool|_|) = function "true" -> Some true | "false" -> Some false | _ -> None + + [] // Should fail + [] + let (|BoolExpr2|_|) = function "true" -> ValueSome true | "false" -> ValueSome false | _ -> ValueNone + + [] // Should fail + let (|BoolExpr3|_|) x = + match x with + | "true" -> Some true + | "false" -> Some false + | _ -> None + + [] // Should fail + [] + let (|BoolExpr4|_|) x = + match x with + | "true" -> ValueSome true + | "false" -> ValueSome false + | _ -> ValueNone + + [] // Should fail + let rec func12() = 0 + and [] func13() = [] // Should fail + + [] // Should fail + let rec func14() = 0 \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod02.fs new file mode 100644 index 0000000000..8687a9b1d0 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod02.fs @@ -0,0 +1,40 @@ +// This tests that AttributeTargets.Method is not allowed in let bound values + +open System + +[] +type MethodOnlyAttribute() = + inherit Attribute() + +[] // Should fail +let val1 = "someValue" + +[] // Should fail +let i, j, k = (1, 2, 3) + +[] // Should fail +let val2 = nameof(MethodOnlyAttribute) + +[] // Should fail +let rec val3 = nameof(val2) + +[] // Should fail +let ``val4`` = "someValue" + +[] // Should fail +let rec val5 = 0 +and [] val6 = [] // Should fail + +[] // Should fail +let (a :: _) = [] + +[] // Should fail +let (d, e) as val7 = 1, 2 + +[] // Should fail +let 1 = 0 + +type X = { X: int } + +[] // Should fail +let { X = _ } = { X = 1 } diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod03.fs new file mode 100644 index 0000000000..c60ecae32b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsMethod03.fs @@ -0,0 +1,54 @@ +// This tests that AttributeTargets.Method is not allowed in class let bound values + +open System +open System.Diagnostics + +[] +type MethodOnlyAttribute() = + inherit Attribute() + +type TestClass() = + + [] // Should fail + static let val1 = "someValue" + + [] // Should fail + static let rec val2 = "someValue" + + [] // Should fail + static let rec val3 = "someValue" + and [] val4 = "someValue" // Should fail + + [] // Should fail + let val5 = "someValue" + + [] // Should fail + let i, j, k = (1, 2, 3) + + [] // Should fail + let val5 = nameof(MethodOnlyAttribute) + + [] // Should fail + let rec val6 = nameof(val5) + + [] // Should fail + let ``val7`` = "someValue" + + [] // Should fail + let rec val8 = 0 + and [] val9 = [] // Should fail + + [] // Should fail + let (a :: _) = [] + + [] // Should fail + let (d, e) as foo = 1, 2 + + [] // Should fail + let 1 = 0 + + type X = { X: int } + + [] // Should fail + let { X = _ } = { X = 1 } + diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs index 5657287971..9d34b2466e 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/TailCallAttribute.fs @@ -1440,7 +1440,7 @@ namespace N ] [] - let ``Warn about attribute on non-recursive let-bound value`` () = + let ``Error about attribute on non-recursive let-bound value`` () = """ namespace N @@ -1453,18 +1453,10 @@ namespace N |> withLangVersionPreview |> compile |> shouldFail - |> withResults [ - { Error = Warning 3861 - Range = { StartLine = 7 - StartColumn = 13 - EndLine = 7 - EndColumn = 18 } - Message = - "The TailCall attribute should only be applied to recursive functions." } - ] + |> withSingleDiagnostic (Error 842, Line 6, Col 11, Line 6, Col 19, "This attribute is not valid for use on this language element") [] - let ``Warn about attribute on recursive let-bound value`` () = + let ``Error about attribute on recursive let-bound value`` () = """ namespace N @@ -1477,15 +1469,7 @@ namespace N |> withLangVersionPreview |> compile |> shouldFail - |> withResults [ - { Error = Warning 3861 - Range = { StartLine = 7 - StartColumn = 17 - EndLine = 7 - EndColumn = 37 } - Message = - "The TailCall attribute should only be applied to recursive functions." } - ] + |> withSingleDiagnostic (Error 842, Line 6, Col 11, Line 6, Col 19, "This attribute is not valid for use on this language element") [] let ``Warn about self-defined attribute`` () = // is the analysis available for users of older FSharp.Core versions diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 0336edf78b..c375f1c039 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -4751,17 +4751,17 @@ type TestRecord = { B : int } module Test = [)>] - let withType = 0 + let withType() = 0 [>)>] - let withGenericType = 0 + let withGenericType() = 0 [)>] - let withTupleType = 0 + let withTupleType() = 0 [ int>)>] - let withFuncType = 0 + let withFuncType() = 0 [; typeof |])>] - let withTypeArray = 0 + let withTypeArray() = 0 [] - let withIntArray = 0 + let withIntArray() = 0 module NestedModule = type NestedRecordType = { B : int } From 4e1542aff8c14d6af748dd878c2c073e3c778108 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 26 Feb 2024 14:07:57 +0100 Subject: [PATCH 22/24] Disable fuzzing tests (#16763) They get in the way of insertions too often --- .../FSharpChecker/TransparentCompiler.fs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs index 0b6daf9606..3a8730043a 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs +++ b/tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs @@ -646,10 +646,12 @@ let fuzzingTest seed (project: SyntheticProject) = task { } +(* This gets in the way of insertions too often now, uncomment when stable. [] [] [] [] +*) let Fuzzing signatureFiles = let seed = System.Random().Next() From beb01a048ce69126f4517936630e9c3d528defbf Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:40:01 -0800 Subject: [PATCH 23/24] [main] Update dependencies from dotnet/source-build-reference-packages (#16757) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20240223.3 Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 9.0.0-alpha.1.24119.1 -> To Version 9.0.0-alpha.1.24123.3 * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20240223.3 Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 9.0.0-alpha.1.24119.1 -> To Version 9.0.0-alpha.1.24123.3 * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20240223.3 Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 9.0.0-alpha.1.24119.1 -> To Version 9.0.0-alpha.1.24123.3 --------- Co-authored-by: dotnet-maestro[bot] Co-authored-by: Vlad Zarytovskii --- eng/Version.Details.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 19f3a32a34..c30f8e1630 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,9 +1,9 @@ - + https://github.com/dotnet/source-build-reference-packages - 539af5d8ae183d4fe61e8b2f8f4a8505c8a765a7 + 62fb9a85e5c4af657b0014fd6d6588c139d0bb4f From bc3dd9ffaaad7898a68de4828aa0a08e1bb1461b Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Mon, 26 Feb 2024 19:53:33 +0100 Subject: [PATCH 24/24] Disable flaky transparent compiler tests (#16765) --- tests/service/ProjectAnalysisTests.fs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index c375f1c039..901484b6a1 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -4655,7 +4655,7 @@ let callToOverload = B(5).Overload(4) let args = mkProjectCommandLineArgs (dllName, []) [] -[] +// [] // Flaky, reenable when stable [] let ``Test project36 FSharpMemberOrFunctionOrValue.IsBaseValue`` useTransparentCompiler = let keepAssemblyContentsChecker = FSharpChecker.Create(keepAssemblyContents=true, useTransparentCompiler=useTransparentCompiler) @@ -4672,7 +4672,7 @@ let ``Test project36 FSharpMemberOrFunctionOrValue.IsBaseValue`` useTransparentC |> fun baseSymbol -> shouldEqual true baseSymbol.IsBaseValue [] -[] +// [] // Flaky, reenable when stable [] let ``Test project36 FSharpMemberOrFunctionOrValue.IsConstructorThisValue & IsMemberThisValue`` useTransparentCompiler = let keepAssemblyContentsChecker = FSharpChecker.Create(keepAssemblyContents=true, useTransparentCompiler=useTransparentCompiler) @@ -4711,7 +4711,7 @@ let ``Test project36 FSharpMemberOrFunctionOrValue.IsConstructorThisValue & IsMe |> shouldEqual true [] -[] +// [] // Flaky, reenable when stable [] let ``Test project36 FSharpMemberOrFunctionOrValue.LiteralValue`` useTransparentCompiler = let keepAssemblyContentsChecker = FSharpChecker.Create(keepAssemblyContents=true, useTransparentCompiler=useTransparentCompiler) @@ -5329,7 +5329,7 @@ let foo (a: Foo): bool = let options = { checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) with SourceFiles = fileNames } [] -[] +// [] // Flaky, reenable when stable [] let ``Test typed AST for struct unions`` useTransparentCompiler = // See https://github.com/fsharp/FSharp.Compiler.Service/issues/756 let keepAssemblyContentsChecker = FSharpChecker.Create(keepAssemblyContents=true, useTransparentCompiler=useTransparentCompiler) @@ -5419,7 +5419,7 @@ let ``Test diagnostics with line directives ignored`` () = //------------------------------------------------------ [] -[] +// [] // Flaky, reenable when stable [] let ``ParseAndCheckFileResults contains ImplFile list if FSharpChecker is created with keepAssemblyContent flag set to true`` useTransparentCompiler = @@ -5463,7 +5463,7 @@ type A(i:int) = | None -> failwith "declaration list is empty" [] -[] +// [] // Flaky, reenable when stable [] let ``TryGetRecentCheckResultsForFile called with snapshot returns cached result after ParseAndCheckFile`` useTransparentCompiler = let fileName1 = Path.ChangeExtension(tryCreateTemporaryFileName (), ".fs") @@ -5538,7 +5538,7 @@ let ``#4030, Incremental builder creation warnings`` (args, errorSeverities) = //------------------------------------------------------ [] -[] +// [] // Flaky, reenable when stable [] let ``Unused opens in rec module smoke test 1`` useTransparentCompiler = @@ -5613,7 +5613,7 @@ type UseTheThings(i:int) = unusedOpensData |> shouldEqual expected [] -[] +// [] // Flaky, reenable when stable [] let ``Unused opens in non rec module smoke test 1`` useTransparentCompiler = @@ -5688,7 +5688,7 @@ type UseTheThings(i:int) = unusedOpensData |> shouldEqual expected [] -[] +// [] // Flaky, reenable when stable [] let ``Unused opens smoke test auto open`` useTransparentCompiler = @@ -5861,4 +5861,4 @@ module internal EmptyProject = let ``Empty source list produces error FS0207`` () = let results = checker.ParseAndCheckProject(EmptyProject.options) |> Async.RunImmediate results.Diagnostics.Length |> shouldEqual 1 - results.Diagnostics[0].ErrorNumber |> shouldEqual 207 \ No newline at end of file + results.Diagnostics[0].ErrorNumber |> shouldEqual 207