diff --git a/.agents/skills/update-fcs-nightly/SKILL.md b/.agents/skills/update-fcs-nightly/SKILL.md new file mode 100644 index 000000000..e4bd9a04b --- /dev/null +++ b/.agents/skills/update-fcs-nightly/SKILL.md @@ -0,0 +1,135 @@ +--- +name: update-fcs-nightly +description: Judge whether a newer FCS nightly is worth taking, then move the nightly branch to it, port FSAC to what changed, and get the tests green with both compilers. +--- + +# Update the nightly FCS + +The `nightly` branch builds FsAutoComplete (FSAC) against FSharp.Compiler.Service (FCS) and FSharp.Core built from +dotnet/fsharp `main`. You rebase it on the latest FSAC `main`, move it to the newest nightly FCS, port FSAC to what FCS +changed, and end with a green suite under both compilers. Its main use is to catch transparent compiler changes before +they ship, so a failure under one compiler only is the most valuable thing you can find. + +## How nightly is wired + +- The main paket group stays on the stable FCS. Every FSharp.Analyzers.SDK release pins FSharp.Core to an exact + version, so the nightly packages cannot enter that group. +- The `FcsNightly` group in `paket.dependencies` downloads the nightly FCS and FSharp.Core from a dotnet/dotnet feed + (`dotnet12` and later). Their versions are also in `FcsNightlyVersion` and `FSharpCoreNightlyVersion` in + `Directory.Build.props`. `scripts/bump.fsx` keeps the two in sync. +- The `UseFcsNightly` target in `Directory.Build.targets` swaps the nightly assemblies in for every project that + resolves FSharp.Compiler.Service. +- The main group pins a System.* package where the nightly FCS references a newer version than net8.0 and net9.0 + ship (System.Reflection.Metadata). The build shows the next one as an MSB3277 version conflict. +- `nightly` is FSAC `main` plus one commit per earlier update (`git log main..nightly`). Each message records the API + ports and behaviour changes of that update. Read them before you port. +- Every update rebases `nightly`, so publishing it is a force push. The `nightly` ruleset on ionide/FsAutoComplete + blocks force pushes and deletion for everyone but repository admins. + +## Steps + +### 1. Judge whether the newest nightly is worth it + +``` +dotnet fsi .agents/skills/update-fcs-nightly/scripts/bump.fsx --dry-run +``` + +When it prints `is already the newest`, tell the user and stop. When the user named a version, pass it as the last +argument. Otherwise keep the `dotnet/fsharp changes` link: it is the change log for this update. + +List the commits that touch the checker, in the range of the link and on dotnet/fsharp `main` after its end. The +second list is merged but in no nightly yet: the feed lags `main` by days. The version suffix is the build date +(`26521` is 2026, then month × 50 + day: 21 October), not the date of the last commit in it. + +``` +.agents/skills/update-fcs-nightly/scripts/service-commits.sh +.agents/skills/update-fcs-nightly/scripts/service-commits.sh main +gh api repos/dotnet/fsharp/compare/...main --jq '.commits[].commit.message | split("\n")[0]' | rg FCSMinorVersion +``` + +The script filters on files, not titles: a title like "Completion: respect EditorBrowsableAttribute" hides an `.fsi` +change. Sort each commit by the files it lists: + +- `TransparentCompiler.*`, `FSharpProjectSnapshot.fs`: transparent compiler. +- `BackgroundCompiler.*`, `IncrementalBuild.*`: background compiler. +- `service.*`, `FSharpCheckerResults.*`, `Caches.*` and the rest, or files of both lists above: both compilers. +- Any `.fsi`: an API port to expect. + +Read the PR of each one (`gh pr view -R dotnet/fsharp --json title,author,body`) for what it fixes and any +numbers it measured. Report to the user: + +- the old and new version, and the `dotnet/fsharp changes` link; +- the transparent compiler changes, then the changes to both compilers or to the background compiler only, one line + each with the PR number and what it fixes; +- the API ports to expect: the `.fsi` files changed; +- the same kinds of change merged on `main` but in no nightly yet, and an `FCSMinorVersion` bump, which moves the + next nightly to a new minor version; +- a recommendation: update now, or wait for the named pending PRs. + +Done when the user has decided. Go on to step 2 only on their go-ahead. + +### 2. Rebase on the latest main + +Fetch the remote that points at ionide/FsAutoComplete, check out `nightly`, and rebase it on `/main`. Resolve +conflicts commit by commit: + +- `paket.lock`: take the side of the rebase base (`git checkout --ours paket.lock`), then run `dotnet paket install` + to add the commit's `FcsNightly` group again, and stage the result. +- Every other file: keep both main's change and the commit's change. When main reformatted the file, write the + commit's change in main's new layout. + +Done when the rebase has finished, `git log HEAD../main` is empty, and the working tree is clean. + +### 3. Bump + +Run the command of step 1 without `--dry-run`, then: + +``` +dotnet paket install +dotnet restore --force +``` + +The forced restore matters: after a lock file change, restore can report "up-to-date" and keep the old package +graph in `obj/`. + +Done when the `FcsNightly` group in `paket.lock` has the new versions and the main group did not change. + +### 4. Build + +`dotnet build` at the root builds every target framework and the tests, with warnings as errors. Port FSAC to each +error: find the FCS change in the commit range (a dotnet/fsharp clone with `git log -S`, or the `.fsi` files at the +new commit) and use the new FCS API. + +Done when the build has 0 errors and 0 warnings, and +`src/FsAutoComplete/bin/Debug/net10.0/FSharp.Compiler.Service.dll` is byte-identical (`cmp`) to +`~/.nuget/packages/fsharp.compiler.service//lib/netstandard2.0/FSharp.Compiler.Service.dll`. + +### 5. Test + +Run the full net10.0 suite as "Running Tests" in `AGENTS.md` describes, once with +`USE_TRANSPARENT_COMPILER=TransparentCompiler` and once with `BackgroundCompiler`. Send each run to its own log file: +tests that expect exceptions log long stack traces, and the result is the closing `EXPECTO!` line. Triage every +failure: + +- **Under both compilers, the same failure**: an FCS behaviour change. Find the commit in the range. Adapt FSAC when + its behaviour should stay; update the test when the FCS change is an improvement and the test's intent still holds. + Name the dotnet/fsharp PR in a comment at the change. +- **Under one compiler only**: a transparent compiler (or background compiler) change, the finding this branch + exists for. Leave the test as it is, find the suspect commits in the range, and report it. + +Done when both `EXPECTO!` lines report `0 failed, 0 errored`, or every remaining failure is a reported one-compiler +finding. + +### 6. Format + +`dotnet fantomas .` from the repository root. `.fantomasignore` skips the test case projects. + +### 7. Commit and report + +The update is one new commit on top of the rebased ones. Its message names the old and new version and the +`dotnet/fsharp changes` link, and lists the API ports and the behaviour changes with their dotnet/fsharp PR numbers +(or says that FSAC needed none). + +Report to the user: the old and new version, the `dotnet/fsharp changes` link, the API ports, the behaviour changes +with their dotnet/fsharp PR numbers, the test counts per compiler, every one-compiler finding, and what is left. +Publishing is left to a repository admin: `git push --force-with-lease nightly`. diff --git a/.agents/skills/update-fcs-nightly/scripts/bump.fsx b/.agents/skills/update-fcs-nightly/scripts/bump.fsx new file mode 100644 index 000000000..a6a312cb7 --- /dev/null +++ b/.agents/skills/update-fcs-nightly/scripts/bump.fsx @@ -0,0 +1,178 @@ +// Moves the FcsNightly paket group and Directory.Build.props to a newer FCS from the dotnet/dotnet feeds. +// +// Usage: dotnet fsi bump.fsx [--dry-run] [version] +// version an exact FSharp.Compiler.Service version; the newest one on the feeds when left out +// --dry-run print what would change, and edit nothing +// +// Prints the FCS and FSharp.Core versions, the feed, and the dotnet/fsharp commit range between the +// current and the new version. It does not run paket: run `dotnet paket install` afterwards. + +open System +open System.IO +open System.Net.Http +open System.Text.Json +open System.Text.RegularExpressions + +// scripts -> update-fcs-nightly -> skills -> .agents -> repository root +let repositoryRoot = + Path.GetFullPath(Path.Combine(__SOURCE_DIRECTORY__, "..", "..", "..", "..")) + +let paketDependencies = Path.Combine(repositoryRoot, "paket.dependencies") +let buildProps = Path.Combine(repositoryRoot, "Directory.Build.props") + +/// The feeds the VMR publishes to. A new major appears when dotnet/dotnet main moves to the next .NET. +let feeds = [ "dotnet11"; "dotnet12"; "dotnet13"; "dotnet14" ] + +let feedIndex feed = + $"https://pkgs.dev.azure.com/dnceng/public/_packaging/%s{feed}/nuget/v3/index.json" + +let flatContainer feed = $"https://pkgs.dev.azure.com/dnceng/public/_packaging/%s{feed}/nuget/v3/flat2" + +let http = new HttpClient() + +let tryGetString (url: string) = + use response = http.GetAsync(url).Result + + if response.IsSuccessStatusCode then + Some(response.Content.ReadAsStringAsync().Result) + else + None + +/// SemVer 2 order: release after prerelease, numeric identifiers compared as numbers. +let compareVersions (a: string) (b: string) = + let split (v: string) = + match v.Split('-', 2) with + | [| core; pre |] -> core, Some pre + | _ -> v, None + + let compareIdentifier (x: string) (y: string) = + match Int64.TryParse x, Int64.TryParse y with + | (true, x), (true, y) -> compare x y + | (true, _), _ -> -1 + | _, (true, _) -> 1 + | _ -> String.CompareOrdinal(x, y) + + let compareIdentifiers (xs: string array) (ys: string array) = + Seq.zip xs ys + |> Seq.map (fun (x, y) -> compareIdentifier x y) + |> Seq.tryFind ((<>) 0) + |> Option.defaultValue (compare xs.Length ys.Length) + + let coreA, preA = split a + let coreB, preB = split b + + match compareIdentifiers (coreA.Split '.') (coreB.Split '.') with + | 0 -> + match preA, preB with + | None, None -> 0 + | None, Some _ -> 1 + | Some _, None -> -1 + | Some x, Some y -> compareIdentifiers (x.Split '.') (y.Split '.') + | c -> c + +let fcsVersions feed = + tryGetString $"%s{flatContainer feed}/fsharp.compiler.service/index.json" + |> Option.map (fun json -> + use doc = JsonDocument.Parse json + + [ + for v in doc.RootElement.GetProperty("versions").EnumerateArray() -> feed, v.GetString() + ]) + |> Option.defaultValue [] + +let nuspec feed fcsVersion = + tryGetString $"%s{flatContainer feed}/fsharp.compiler.service/%s{fcsVersion}/fsharp.compiler.service.nuspec" + |> Option.defaultWith (fun () -> failwith $"No nuspec for FCS %s{fcsVersion} on %s{feed}") + +/// FCS pins FSharp.Core to the exact version built with it. +let fsharpCoreVersion (nuspec: string) = + Regex.Match(nuspec, """]*commit="([0-9a-f]+)""").Groups[1].Value + + tryGetString $"https://raw.githubusercontent.com/dotnet/dotnet/%s{vmrCommit}/src/source-manifest.json" + |> Option.bind (fun json -> + use doc = JsonDocument.Parse json + + doc.RootElement.GetProperty("repositories").EnumerateArray() + |> Seq.tryFind (fun r -> r.GetProperty("path").GetString() = "fsharp") + |> Option.map (fun r -> r.GetProperty("commitSha").GetString())) + +let currentFcsVersion () = + Regex.Match(File.ReadAllText buildProps, "([^<]+)").Groups[1].Value + +let replace (pattern: string) (replacement: string) (path: string) = + let text = File.ReadAllText path + + if not (Regex.IsMatch(text, pattern, RegexOptions.Multiline)) then + failwith $"Pattern '%s{pattern}' did not match in %s{path}" + + File.WriteAllText(path, Regex.Replace(text, pattern, replacement, RegexOptions.Multiline)) + +let args = fsi.CommandLineArgs |> Array.skip 1 |> List.ofArray +let dryRun = List.contains "--dry-run" args +let requested = args |> List.tryFind (fun a -> a.Length > 0 && Char.IsDigit a[0]) + +if not (File.Exists paketDependencies && File.Exists buildProps) then + failwith $"No paket.dependencies and Directory.Build.props in %s{repositoryRoot}" + +let candidates = feeds |> List.collect fcsVersions + +let feed, fcsVersion = + match requested with + | Some v -> + candidates + |> List.tryFind (fun (_, c) -> c = v) + |> Option.defaultWith (fun () -> failwith $"FCS %s{v} is on none of the feeds %A{feeds}") + | None -> + candidates + |> List.sortWith (fun (_, a) (_, b) -> compareVersions a b) + |> List.last + +let previous = currentFcsVersion () +let spec = nuspec feed fcsVersion +let coreVersion = fsharpCoreVersion spec + +if not dryRun then + // Only the FcsNightly group pins exact versions; its lines are indented. + paketDependencies + |> replace + @"^(\s+source https://pkgs\.dev\.azure\.com/dnceng/public/_packaging/)dotnet\d+(/nuget/v3/index\.json)[ \t]*$" + $"${{1}}%s{feed}${{2}}" + + paketDependencies + |> replace @"^(\s+nuget FSharp\.Compiler\.Service )\S+[ \t]*$" $"${{1}}%s{fcsVersion}" + + paketDependencies + |> replace @"^(\s+nuget FSharp\.Core )\S+[ \t]*$" $"${{1}}%s{coreVersion}" + + buildProps + |> replace "[^<]+" $"%s{fcsVersion}" + + buildProps + |> replace + "[^<]+" + $"%s{coreVersion}" + +let verb = if dryRun then "would move" else "moved" + +if previous = fcsVersion then + printfn $"FCS %s{fcsVersion} is already the newest (FSharp.Core %s{coreVersion}, %s{feedIndex feed})" +else + printfn $"FCS %s{verb} %s{previous} -> %s{fcsVersion} (FSharp.Core %s{coreVersion}) from %s{feedIndex feed}" + +let previousCommit = + if previous = "" || previous = fcsVersion then + None + else + candidates + |> List.tryFind (fun (_, v) -> v = previous) + |> Option.bind (fun (f, v) -> fsharpCommit (nuspec f v)) + +match previousCommit, fsharpCommit spec with +| Some a, Some b when a <> b -> printfn $"dotnet/fsharp changes: https://github.com/dotnet/fsharp/compare/%s{a}...%s{b}" +| _, Some b -> printfn $"dotnet/fsharp commit: https://github.com/dotnet/fsharp/commit/%s{b}" +| _ -> () diff --git a/.agents/skills/update-fcs-nightly/scripts/service-commits.sh b/.agents/skills/update-fcs-nightly/scripts/service-commits.sh new file mode 100755 index 000000000..c5b0b940d --- /dev/null +++ b/.agents/skills/update-fcs-nightly/scripts/service-commits.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Lists the dotnet/fsharp commits in ... that touch the checker: src/Compiler/Service/ and +# src/Compiler/Utilities/Caches.*. One line per commit: short sha | title (#PR) | the files it touches there. +# +# Usage: service-commits.sh +# can be a branch, e.g. main for the commits not yet in a nightly. +set -euo pipefail + +from=$1 +to=$2 + +gh api "repos/dotnet/fsharp/compare/$from...$to" --jq '.commits[].sha' | + while read -r sha; do + gh api "repos/dotnet/fsharp/commits/$sha" --jq ' + [ .sha[0:9], + (.commit.message | split("\n")[0]), + ([.files[].filename | select(test("^src/Compiler/(Service/|Utilities/Caches)"))] + | map(split("/") | last) | unique | join(" ")) ] + | select(.[2] != "") + | join(" | ")' + done diff --git a/Directory.Build.props b/Directory.Build.props index 531a023d9..0f072eed4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -22,6 +22,9 @@ false true + + 43.14.200-rc2.26569.113 + 11.0.200-rc2.26569.113 diff --git a/Directory.Build.targets b/Directory.Build.targets index 013730228..afa7015b6 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -8,6 +8,26 @@ + + + + <_FcsNightlyDir>$(NuGetPackageRoot)fsharp.compiler.service/$(FcsNightlyVersion)/lib/netstandard2.0/ + <_FSharpCoreNightlyDir>$(NuGetPackageRoot)fsharp.core/$(FSharpCoreNightlyVersion)/lib/netstandard2.1/ + <_UsesFcs>@(ResolvedCompileFileDefinitions->AnyHaveMetadataValue('Filename', 'FSharp.Compiler.Service')) + + + + + + + + + ./ . diff --git a/paket.dependencies b/paket.dependencies index 98d04ec27..58ae650fc 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -3,9 +3,6 @@ version 7.2.1 framework: netstandard2.0, netstandard2.1, net10.0 source https://api.nuget.org/v3/index.json -# this is the FCS nightly feed, re-enable at your own risk! -# source: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json -# source: ./libs storage: none lowest_matching:true strategy: min @@ -62,8 +59,26 @@ nuget CommunityToolkit.HighPerformance nuget System.Security.Cryptography.Pkcs nuget System.Net.Http nuget System.Text.RegularExpressions +# the nightly FCS references System.Reflection.Metadata 10, which net8.0 and net9.0 do not ship +nuget System.Reflection.Metadata >= 10.0.10 ## Test Explorer nuget Microsoft.TestPlatform.TranslationLayer nuget Microsoft.TestPlatform.ObjectModel + +## Nightly FCS and FSharp.Core, built from dotnet/fsharp main. +## Every FSharp.Analyzers.SDK release pins FSharp.Core to an exact version, so the main group stays on +## the stable FCS and Directory.Build.targets swaps in these assemblies at build time. +## Update with the update-fcs-nightly skill (.agents/skills/update-fcs-nightly), which keeps these versions in sync +## with FcsNightlyVersion and FSharpCoreNightlyVersion in Directory.Build.props. +group FcsNightly + source https://api.nuget.org/v3/index.json + source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet12/nuget/v3/index.json + storage: none + lowest_matching: true + strategy: min + framework: netstandard2.0, netstandard2.1 + + nuget FSharp.Compiler.Service 43.14.200-rc2.26569.113 + nuget FSharp.Core 11.0.200-rc2.26569.113 diff --git a/paket.lock b/paket.lock index 448b3f24a..4f85177be 100644 --- a/paket.lock +++ b/paket.lock @@ -876,3 +876,40 @@ NUGET FSharp.Core (>= 7.0.200) - restriction: || (== net10.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0)) Microsoft.Testing.Extensions.VSTestBridge (>= 2.3.3) - restriction: || (== net10.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0)) Microsoft.Testing.Platform.MSBuild (>= 2.3.3) - restriction: || (== net10.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0)) + +GROUP FcsNightly +STORAGE: NONE +STRATEGY: MIN +LOWEST_MATCHING: TRUE +RESTRICTION: || (== netstandard2.0) (== netstandard2.1) +NUGET + remote: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet12/nuget/v3/index.json + FSharp.Compiler.Service (43.14.200-rc2.26569.113) + FSharp.Core (11.0.200-rc2.26569.113) + System.Buffers (>= 4.6.1) + System.Collections.Immutable (>= 10.0.15) + System.Diagnostics.DiagnosticSource (>= 10.0.15) + System.Memory (>= 4.6.3) + System.Reflection.Emit (>= 4.7) + System.Reflection.Metadata (>= 10.0.15) + System.Runtime.CompilerServices.Unsafe (>= 6.1.2) + FSharp.Core (11.0.200-rc2.26569.113) + remote: https://api.nuget.org/v3/index.json + System.Buffers (4.6.1) + System.Collections.Immutable (10.0.15) + System.Memory (>= 4.6.3) + System.Runtime.CompilerServices.Unsafe (>= 6.1.2) + System.Diagnostics.DiagnosticSource (10.0.15) + System.Memory (>= 4.6.3) + System.Runtime.CompilerServices.Unsafe (>= 6.1.2) + System.Memory (4.6.3) + System.Buffers (>= 4.6.1) - restriction: || (== netstandard2.0) (&& (== netstandard2.1) (>= net462)) + System.Numerics.Vectors (>= 4.6.1) - restriction: || (== netstandard2.0) (&& (== netstandard2.1) (>= net462)) + System.Runtime.CompilerServices.Unsafe (>= 6.1.2) - restriction: || (== netstandard2.0) (&& (== netstandard2.1) (>= net462)) + System.Numerics.Vectors (4.6.1) - restriction: || (== netstandard2.0) (&& (== netstandard2.1) (>= net462)) + System.Reflection.Emit (4.7) + System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (== netstandard2.0) (&& (== netstandard2.1) (< netstandard1.1)) (&& (== netstandard2.1) (< netstandard2.0)) (&& (== netstandard2.1) (>= uap10.1)) + System.Reflection.Emit.ILGeneration (4.7) - restriction: || (== netstandard2.0) (&& (== netstandard2.1) (< netstandard1.1)) (&& (== netstandard2.1) (< netstandard2.0)) (&& (== netstandard2.1) (>= uap10.1)) + System.Reflection.Metadata (10.0.15) + System.Collections.Immutable (>= 10.0.15) + System.Runtime.CompilerServices.Unsafe (6.1.2) diff --git a/src/FsAutoComplete.Core/Commands.fs b/src/FsAutoComplete.Core/Commands.fs index 471a3d839..548701cf5 100644 --- a/src/FsAutoComplete.Core/Commands.fs +++ b/src/FsAutoComplete.Core/Commands.fs @@ -1450,8 +1450,8 @@ type Commands() = member _.VisitComponentInfo(_, synComponentInfo) = match synComponentInfo with - | SynComponentInfo(attributes = attributes; longId = longId; xmlDoc = xmlDoc) when - longIdentContainsPos longId pos && xmlDoc.IsEmpty + | SynComponentInfo(attributes = attributes; xmlDoc = xmlDoc) when + longIdentContainsPos synComponentInfo.LongIdent pos && xmlDoc.IsEmpty -> Some(false, tryGetFirstAttributeLine attributes) | _ -> None @@ -1526,8 +1526,8 @@ type Commands() = match d with | SynModuleDecl.NestedModule(moduleInfo = moduleInfo; decls = decls) -> match moduleInfo with - | SynComponentInfo(attributes = attributes; longId = longId; xmlDoc = xmlDoc) when - longIdentContainsPos longId pos && xmlDoc.IsEmpty + | SynComponentInfo(attributes = attributes; xmlDoc = xmlDoc) when + longIdentContainsPos moduleInfo.LongIdent pos && xmlDoc.IsEmpty -> Some(false, tryGetFirstAttributeLine attributes) | _ -> findNested decls diff --git a/src/FsAutoComplete.Core/CompilerServiceInterface.fs b/src/FsAutoComplete.Core/CompilerServiceInterface.fs index a9707bbf4..b61d11011 100644 --- a/src/FsAutoComplete.Core/CompilerServiceInterface.fs +++ b/src/FsAutoComplete.Core/CompilerServiceInterface.fs @@ -57,7 +57,10 @@ type CompilerProjectOption = member x.SourceFilesTagged = match x with | BackgroundCompiler(options) -> options.SourceFiles |> Array.map Utils.normalizePath |> Array.toList - | TransparentCompiler(snapshot) -> snapshot.SourceFiles |> List.map (fun f -> Utils.normalizePath f.FileName) + | TransparentCompiler(snapshot) -> + snapshot.SourceFiles + |> Array.map (fun f -> Utils.normalizePath f.FileName) + |> Array.toList member x.ReferencedProjectsPath = match x with @@ -65,7 +68,10 @@ type CompilerProjectOption = options.ReferencedProjects |> Array.choose (fun p -> p.ProjectFilePath) |> Array.toList - | TransparentCompiler(snapshot) -> snapshot.ReferencedProjects |> List.choose (fun p -> p.ProjectFilePath) + | TransparentCompiler(snapshot) -> + snapshot.ReferencedProjects + |> Array.choose (fun p -> p.ProjectFilePath) + |> Array.toList member x.LoadTime = match x with @@ -225,7 +231,7 @@ type FSharpCompilerServiceChecker /// ensures that any user-configured include/load files are added to the typechecking context let addLoadedFilesToSnapshot (snapshot: FSharpProjectSnapshot) = - let files = List.append fsiAdditionalFiles snapshot.SourceFiles + let files = Array.append (Array.ofList fsiAdditionalFiles) snapshot.SourceFiles optsLogger.info ( Log.setMessage "Source file list is {files}" diff --git a/src/FsAutoComplete.Core/TestAdapter.fs b/src/FsAutoComplete.Core/TestAdapter.fs index a3dd9dcaf..c222519c9 100644 --- a/src/FsAutoComplete.Core/TestAdapter.fs +++ b/src/FsAutoComplete.Core/TestAdapter.fs @@ -309,7 +309,8 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry list = and visitTypeDef parent t = let (SynTypeDefn(typeInfo = ci; typeRepr = om; members = members)) = t - let (SynComponentInfo(longId = ids; range = r)) = ci + let (SynComponentInfo(range = r)) = ci + let ids = ci.LongIdent let name = String.concat "." [ for i in ids -> i.idText ] let moduleType = @@ -373,7 +374,7 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry list = | SynModuleDecl.Types(typeDefns, _) -> typeDefns |> List.map (fun (SynTypeDefn(typeInfo = ci)) -> - let (SynComponentInfo(longId = ids)) = ci + let ids = ci.LongIdent String.concat "." [ for i in ids -> i.idText ]) |> List.append types | _ -> types) @@ -386,7 +387,8 @@ let getNUnitTest (ast: ParsedInput) : TestAdapterEntry list = for b in bindings do visitBinding parent b | SynModuleDecl.NestedModule(moduleInfo = ci; decls = decls) -> - let (SynComponentInfo(longId = ids; range = r)) = ci + let (SynComponentInfo(range = r)) = ci + let ids = ci.LongIdent let name = String.concat "." [ for i in ids -> i.idText ] let moduleType = @@ -493,7 +495,8 @@ let getXUnitTest ast : TestAdapterEntry list = and visitTypeDef parent t = let (SynTypeDefn(typeInfo = ci; typeRepr = om; members = members)) = t - let (SynComponentInfo(longId = ids; range = r)) = ci + let (SynComponentInfo(range = r)) = ci + let ids = ci.LongIdent let name = String.concat "." [ for i in ids -> i.idText ] let moduleType = @@ -557,7 +560,7 @@ let getXUnitTest ast : TestAdapterEntry list = | SynModuleDecl.Types(typeDefns, _) -> typeDefns |> List.map (fun (SynTypeDefn(typeInfo = ci)) -> - let (SynComponentInfo(longId = ids)) = ci + let ids = ci.LongIdent String.concat "." [ for i in ids -> i.idText ]) |> List.append types | _ -> types) @@ -570,7 +573,8 @@ let getXUnitTest ast : TestAdapterEntry list = for b in bindings do visitBinding parent b | SynModuleDecl.NestedModule(moduleInfo = ci; decls = decls) -> - let (SynComponentInfo(longId = ids; range = r)) = ci + let (SynComponentInfo(range = r)) = ci + let ids = ci.LongIdent let name = String.concat "." [ for i in ids -> i.idText ] let moduleType = diff --git a/src/FsAutoComplete.Core/UntypedAstUtils.fs b/src/FsAutoComplete.Core/UntypedAstUtils.fs index cd0fc1b0e..fd707897e 100644 --- a/src/FsAutoComplete.Core/UntypedAstUtils.fs +++ b/src/FsAutoComplete.Core/UntypedAstUtils.fs @@ -508,8 +508,7 @@ module Syntax = | SynTypeDefnSimpleRepr.Exception _ -> () and walkComponentInfo - (SynComponentInfo( - attributes = AllAttrs attrs; typeParams = typars; constraints = constraints; longId = _; range = _) as s) + (SynComponentInfo(attributes = AllAttrs attrs; typeParams = typars; constraints = constraints; range = _) as s) = walker.WalkComponentInfo s List.iter walkAttribute attrs @@ -776,7 +775,9 @@ module FsacSemanticTokenSites = if not (delegateDeclarationRanges.Contains(id.idRange)) then declarations.Add(id.idRange) - override _.WalkTypeDefn(SynTypeDefn(typeInfo = SynComponentInfo(longId = idents); typeRepr = typeRepr)) = + override _.WalkTypeDefn(SynTypeDefn(typeInfo = typeInfo; typeRepr = typeRepr)) = + let idents = typeInfo.LongIdent + match typeRepr with | SynTypeDefnRepr.ObjectModel(kind = SynTypeDefnKind.Augmentation _) -> () | SynTypeDefnRepr.ObjectModel(SynTypeDefnKind.Delegate _, members, _) -> @@ -788,7 +789,9 @@ module FsacSemanticTokenSites = | _ -> ()) | _ -> tryLastIdentRange idents |> Option.iter definitions.Add - override _.WalkTypeDefnSig(SynTypeDefnSig(typeInfo = SynComponentInfo(longId = idents); typeRepr = typeRepr)) = + override _.WalkTypeDefnSig(SynTypeDefnSig(typeInfo = typeInfo; typeRepr = typeRepr)) = + let idents = typeInfo.LongIdent + match typeRepr with | SynTypeDefnSigRepr.ObjectModel(kind = SynTypeDefnKind.Augmentation _) -> () | SynTypeDefnSigRepr.ObjectModel(SynTypeDefnKind.Delegate _, members, _) -> diff --git a/src/FsAutoComplete/CodeFixes/AddBindingToSignatureFile.fs b/src/FsAutoComplete/CodeFixes/AddBindingToSignatureFile.fs index 1244fd0ce..931837c6c 100644 --- a/src/FsAutoComplete/CodeFixes/AddBindingToSignatureFile.fs +++ b/src/FsAutoComplete/CodeFixes/AddBindingToSignatureFile.fs @@ -103,7 +103,9 @@ let fix | SyntaxNode.SynModuleOrNamespaceSig(SynModuleOrNamespaceSig( longId = longId; range = mParent; decls = decls)) | SyntaxNode.SynModuleSigDecl(SynModuleSigDecl.NestedModule( - moduleInfo = SynComponentInfo(longId = longId); range = mParent; moduleDecls = decls)) -> + moduleInfo = SynComponentInfo(synType = Some(SynType.LongIdent(SynLongIdent(id = longId)))) + range = mParent + moduleDecls = decls)) -> let mSigName = mkLongIdRange longId // `parentSigLocation` will only contain the single identifier in case a module is prefixed with a namespace. diff --git a/src/FsAutoComplete/CodeFixes/AddPrivateAccessModifier.fs b/src/FsAutoComplete/CodeFixes/AddPrivateAccessModifier.fs index 13eb2683e..31d033eab 100644 --- a/src/FsAutoComplete/CodeFixes/AddPrivateAccessModifier.fs +++ b/src/FsAutoComplete/CodeFixes/AddPrivateAccessModifier.fs @@ -75,8 +75,8 @@ let private getRangesAndPlacement input pos = match d with // Nested Module | SynModuleDecl.NestedModule( - moduleInfo = SynComponentInfo(attributes = attributes; longId = longId; accessibility = None) - trivia = { ModuleKeyword = Some r }) as m when longIdentContainsPos longId pos -> + moduleInfo = (SynComponentInfo(attributes = attributes; accessibility = None) as moduleInfo) + trivia = { ModuleKeyword = Some r }) as m when longIdentContainsPos moduleInfo.LongIdent pos -> let editRange = getEditRangeForModule attributes r pos.Line let path = (SyntaxNode.SynModule m) :: path @@ -96,8 +96,8 @@ let private getRangesAndPlacement input pos = match td with // Class Type | SynTypeDefn( - typeInfo = SynComponentInfo(longId = longId; accessibility = None; range = r) - typeRepr = SynTypeDefnRepr.ObjectModel _) as t when longIdentContainsPos longId pos -> + typeInfo = (SynComponentInfo(accessibility = None; range = r) as typeInfo) + typeRepr = SynTypeDefnRepr.ObjectModel _) as t when longIdentContainsPos typeInfo.LongIdent pos -> let editRange = r.WithEnd r.Start let path = SyntaxNode.SynTypeDefn t :: path diff --git a/src/FsAutoComplete/CodeFixes/AddTypeAliasToSignatureFile.fs b/src/FsAutoComplete/CodeFixes/AddTypeAliasToSignatureFile.fs index 9f38aa34a..2e7c55fcd 100644 --- a/src/FsAutoComplete/CodeFixes/AddTypeAliasToSignatureFile.fs +++ b/src/FsAutoComplete/CodeFixes/AddTypeAliasToSignatureFile.fs @@ -55,7 +55,7 @@ let fix ||> ParsedInput.tryPick (fun _path node -> match node with | SyntaxNode.SynTypeDefn(SynTypeDefn( - typeInfo = SynComponentInfo(longId = [ typeIdent ]) + typeInfo = SynComponentInfo(synType = Some(SynType.LongIdent(SynLongIdent(id = [ typeIdent ])))) typeRepr = SynTypeDefnRepr.Simple(simpleRepr = SynTypeDefnSimpleRepr.TypeAbbrev _)) as tdn) when (Range.rangeContainsPos tdn.FullRange fcsPos) -> @@ -88,7 +88,8 @@ let fix match node with | SyntaxNode.SynModuleOrNamespaceSig(SynModuleOrNamespaceSig(longId = longId; decls = decls)) | SyntaxNode.SynModuleSigDecl(SynModuleSigDecl.NestedModule( - moduleInfo = SynComponentInfo(longId = longId); moduleDecls = decls)) -> + moduleInfo = SynComponentInfo(synType = Some(SynType.LongIdent(SynLongIdent(id = longId)))) + moduleDecls = decls)) -> let mSigName = mkLongIdRange longId // `parentSigLocation` will only contain the single identifier in case a module is prefixed with a namespace. diff --git a/src/FsAutoComplete/CodeFixes/UpdateTypeAbbreviationInSignatureFile.fs b/src/FsAutoComplete/CodeFixes/UpdateTypeAbbreviationInSignatureFile.fs index da35d5d11..40e9570bc 100644 --- a/src/FsAutoComplete/CodeFixes/UpdateTypeAbbreviationInSignatureFile.fs +++ b/src/FsAutoComplete/CodeFixes/UpdateTypeAbbreviationInSignatureFile.fs @@ -29,7 +29,7 @@ let fix (getParseResultsForFile: GetParseResultsForFile) : CodeFix = ||> ParsedInput.tryPick (fun _ node -> match node with | SyntaxNode.SynTypeDefn(SynTypeDefn( - typeInfo = SynComponentInfo(longId = [ typeIdent ]) + typeInfo = SynComponentInfo(synType = Some(SynType.LongIdent(SynLongIdent(id = [ typeIdent ])))) typeRepr = SynTypeDefnRepr.Simple(simpleRepr = SynTypeDefnSimpleRepr.TypeAbbrev _; range = mBody))) when Range.equals typeIdent.idRange mDiag -> @@ -57,7 +57,7 @@ let fix (getParseResultsForFile: GetParseResultsForFile) : CodeFix = ||> ParsedInput.tryPick (fun _path node -> match node with | SyntaxNode.SynTypeDefnSig(SynTypeDefnSig( - typeInfo = SynComponentInfo(longId = [ typeIdent ]) + typeInfo = SynComponentInfo(synType = Some(SynType.LongIdent(SynLongIdent(id = [ typeIdent ])))) typeRepr = SynTypeDefnSigRepr.Simple(repr = SynTypeDefnSimpleRepr.TypeAbbrev _; range = m))) when Range.equals typeIdent.idRange signatureLocation -> diff --git a/src/FsAutoComplete/LspServers/ProjectWorkspace.fs b/src/FsAutoComplete/LspServers/ProjectWorkspace.fs index b605e63c9..94b9cd9ba 100644 --- a/src/FsAutoComplete/LspServers/ProjectWorkspace.fs +++ b/src/FsAutoComplete/LspServers/ProjectWorkspace.fs @@ -113,7 +113,8 @@ module Snapshots = originalLoadReferences = let flattenASet (s: aset>) = s |> ASet.mapA id |> ASet.toAVal |> AVal.map HashSet.toList - let flattenAList (s: alist>) = s |> AList.mapA id |> AList.toAVal |> AVal.map IndexList.toList + let flattenASetToArray (s: aset>) = s |> ASet.mapA id |> ASet.toAVal |> AVal.map HashSet.toArray + let flattenAList (s: alist>) = s |> AList.mapA id |> AList.toAVal |> AVal.map IndexList.toArray makeAdaptiveFCSSnapshot projectFileName @@ -122,7 +123,7 @@ module Snapshots = (flattenAList sourceFiles) (flattenASet referencePaths) (flattenASet otherOptions) - (flattenASet referencedProjects) + (flattenASetToArray referencedProjects) isIncompleteTypeCheckEnvironment useScriptResolutionRules loadTime diff --git a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/ToInterpolatedStringTests.fs b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/ToInterpolatedStringTests.fs index 134c7a2b0..dfb4dbd64 100644 --- a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/ToInterpolatedStringTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/ToInterpolatedStringTests.fs @@ -346,11 +346,19 @@ let tests state = testCaseAsync "Reflecting into LanguageVersion - feature unsupported in older version" <| async { - let languageFeature = LanguageFeatureShim("StringInterpolation") + // FCS no longer has a flag for StringInterpolation, so use a feature it still gates. + let languageFeature = LanguageFeatureShim("UnmanagedConstraintCsharpInterop") let languageVersion = LanguageVersionShim("4.7") Expect.equal false (languageVersion.SupportsFeature languageFeature) "" } + testCaseAsync "Reflecting into LanguageVersion - feature without a flag is always on" + <| async { + let languageFeature = LanguageFeatureShim("StringInterpolation") + let languageVersion = LanguageVersionShim("4.7") + Expect.equal true (languageVersion.SupportsFeature languageFeature) "" + } + testCaseAsync "Multiline applications are not supported" <| CodeFix.checkNotApplicable server diff --git a/test/FsAutoComplete.Tests.Lsp/SnapshotTests.fs b/test/FsAutoComplete.Tests.Lsp/SnapshotTests.fs index 8648e96a8..c3f161256 100644 --- a/test/FsAutoComplete.Tests.Lsp/SnapshotTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/SnapshotTests.fs @@ -324,7 +324,7 @@ let snapshotTests loaders toolsPath = ) match console.ReferencedProjects with - | [ FSharpReferencedProjectSnapshot.PEReference(_, reader) ] -> + | [| FSharpReferencedProjectSnapshot.PEReference(_, reader) |] -> Expect.equal (Path.GetFileName reader.OutputFile) "Library1.dll"