Skip to content

Commit afa5809

Browse files
Reenabling ReplaceWithSuggestion for FS1129 (#16020)
Co-authored-by: Vlad Zarytovskii <[email protected]>
1 parent 7cd0fb2 commit afa5809

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

vsintegration/src/FSharp.Editor/CodeFixes/ReplaceWithSuggestion.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ open CancellableTasks
1919
type internal ReplaceWithSuggestionCodeFixProvider [<ImportingConstructor>] () =
2020
inherit CodeFixProvider()
2121

22-
override _.FixableDiagnosticIds = ImmutableArray.Create("FS0039", "FS0495")
22+
override _.FixableDiagnosticIds = ImmutableArray.Create("FS0039", "FS0495", "FS1129")
2323

2424
override this.RegisterCodeFixesAsync context =
2525
if context.Document.Project.IsFSharpCodeFixesSuggestNamesForErrorsEnabled then

vsintegration/tests/FSharp.Editor.Tests/CodeFixes/ReplaceWithSuggestionTests.fs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,37 @@ let song = Song(title = "Under The Milky Way")
156156
let actual = codeFix |> multiFix code Auto
157157

158158
Assert.Equal(expected, actual)
159+
160+
[<Fact>]
161+
let ``Fixes FS1129`` () =
162+
let code =
163+
"""
164+
type SomeType = { TheField : string }
165+
166+
let f x =
167+
match x with
168+
| { TheField = "A" } -> true
169+
| { TheFiedl = "B" } -> true
170+
| _ -> false
171+
"""
172+
173+
let expected =
174+
[
175+
{
176+
Message = "Replace with 'TheField'"
177+
FixedCode =
178+
"""
179+
type SomeType = { TheField : string }
180+
181+
let f x =
182+
match x with
183+
| { TheField = "A" } -> true
184+
| { TheField = "B" } -> true
185+
| _ -> false
186+
"""
187+
}
188+
]
189+
190+
let actual = codeFix |> multiFix code Auto
191+
192+
Assert.Equal(expected, actual)

0 commit comments

Comments
 (0)