From 4db45670ec5e662bdadf7554b2d57d440875ebb2 Mon Sep 17 00:00:00 2001 From: Petr Date: Fri, 22 Sep 2023 14:22:52 +0200 Subject: [PATCH] Reenabling ReplaceWithSuggestion for FS1129 --- .../CodeFixes/ReplaceWithSuggestion.fs | 2 +- .../CodeFixes/ReplaceWithSuggestionTests.fs | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/vsintegration/src/FSharp.Editor/CodeFixes/ReplaceWithSuggestion.fs b/vsintegration/src/FSharp.Editor/CodeFixes/ReplaceWithSuggestion.fs index 31b0b84d374..1678f89c1d5 100644 --- a/vsintegration/src/FSharp.Editor/CodeFixes/ReplaceWithSuggestion.fs +++ b/vsintegration/src/FSharp.Editor/CodeFixes/ReplaceWithSuggestion.fs @@ -19,7 +19,7 @@ open CancellableTasks type internal ReplaceWithSuggestionCodeFixProvider [] () = inherit CodeFixProvider() - override _.FixableDiagnosticIds = ImmutableArray.Create("FS0039", "FS0495") + override _.FixableDiagnosticIds = ImmutableArray.Create("FS0039", "FS0495", "FS1129") override this.RegisterCodeFixesAsync context = if context.Document.Project.IsFSharpCodeFixesSuggestNamesForErrorsEnabled then diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/ReplaceWithSuggestionTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/ReplaceWithSuggestionTests.fs index 20495583a37..7f5e745b0f3 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/ReplaceWithSuggestionTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/ReplaceWithSuggestionTests.fs @@ -156,3 +156,37 @@ let song = Song(title = "Under The Milky Way") let actual = codeFix |> multiFix code Auto Assert.Equal(expected, actual) + +[] +let ``Fixes FS1129`` () = + let code = + """ +type SomeType = { TheField : string } + +let f x = + match x with + | { TheField = "A" } -> true + | { TheFiedl = "B" } -> true + | _ -> false +""" + + let expected = + [ + { + Message = "Replace with 'TheField'" + FixedCode = + """ +type SomeType = { TheField : string } + +let f x = + match x with + | { TheField = "A" } -> true + | { TheField = "B" } -> true + | _ -> false +""" + } + ] + + let actual = codeFix |> multiFix code Auto + + Assert.Equal(expected, actual)