Skip to content

Commit 52437eb

Browse files
xperiandriclaude
andcommitted
Cover the qualification suggestions the fix offers alongside the opens
The tests filtered the suggestions down to the opens, so what the fix offers for qualifying the name in place went unasserted — including that three of them is where the list stops. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8d73cb4 commit 52437eb

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

‎vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddOpenOnTopOnTests.fs‎

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ open CodeFixTestFramework
1111

1212
let private codeFix = AddOpenCodeFixProvider(AssemblyContentProvider())
1313

14-
/// Every `open` suggestion the fix offers, in the order the lightbulb lists them.
14+
/// Everything the fix offers, in the order the lightbulb lists it: the opens, then the qualifications.
15+
let private allFixes code mode =
16+
codeFix |> multiFix code mode |> Seq.toList
17+
18+
/// Just the `open` suggestions, for the tests that are about where the declaration lands.
1519
let private openFixes code mode =
16-
codeFix
17-
|> multiFix code mode
18-
|> Seq.filter (fun fix -> fix.Message.StartsWith("open ", StringComparison.Ordinal))
19-
|> Seq.toList
20+
allFixes code mode
21+
|> List.filter (fun fix -> fix.Message.StartsWith("open ", StringComparison.Ordinal))
2022

2123
[<Fact>]
2224
let ``Fixes FS0039 for missing opens - basic`` () =
@@ -529,6 +531,29 @@ let readFile () = File.ReadAllText "example.txt"
529531

530532
Assert.Equal<TestCodeFix list>(expected, actual)
531533

534+
[<Fact>] // Qualifying the name in place is offered alongside opening what holds it
535+
let ``Offers qualifying the name after the opens`` () =
536+
let code =
537+
"""module Module1
538+
539+
let readFile () = File.ReadAllText "example.txt"
540+
"""
541+
542+
let expected =
543+
[
544+
"open System.IO"
545+
"open type System.Net.WebRequestMethods"
546+
// Qualifications, three of them at most, `System.IO.File` twice over because the type and
547+
// the member being reached through it are both candidates.
548+
"System.IO.File"
549+
"System.IO.File.ReadAllText"
550+
"System.Net.WebRequestMethods.File"
551+
]
552+
553+
let actual = allFixes code Auto |> List.map _.Message
554+
555+
Assert.Equal<string list>(expected, actual)
556+
532557
[<Fact>] // `WriteLine` is a static member of four different types, `System` ones offered first
533558
let ``Offers every type a static member can be resolved from`` () =
534559
let code =

0 commit comments

Comments
 (0)