From a528b819327a98be8f36ab51b801c4eb22bbd7bd Mon Sep 17 00:00:00 2001 From: cartermp Date: Sat, 14 Nov 2020 13:58:22 -0800 Subject: [PATCH 1/2] Add ConvertToSingleEqualsEqualityExpression code fix --- ...ConvertToSingleEqualsEqualityExpression.fs | 46 +++++++++++++++++++ .../src/FSharp.Editor/FSharp.Editor.fsproj | 1 + .../src/FSharp.Editor/FSharp.Editor.resx | 3 ++ .../FSharp.Editor/xlf/FSharp.Editor.cs.xlf | 5 ++ .../FSharp.Editor/xlf/FSharp.Editor.de.xlf | 5 ++ .../FSharp.Editor/xlf/FSharp.Editor.es.xlf | 5 ++ .../FSharp.Editor/xlf/FSharp.Editor.fr.xlf | 5 ++ .../FSharp.Editor/xlf/FSharp.Editor.it.xlf | 5 ++ .../FSharp.Editor/xlf/FSharp.Editor.ja.xlf | 5 ++ .../FSharp.Editor/xlf/FSharp.Editor.ko.xlf | 5 ++ .../FSharp.Editor/xlf/FSharp.Editor.pl.xlf | 5 ++ .../FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf | 5 ++ .../FSharp.Editor/xlf/FSharp.Editor.ru.xlf | 5 ++ .../FSharp.Editor/xlf/FSharp.Editor.tr.xlf | 5 ++ .../xlf/FSharp.Editor.zh-Hans.xlf | 5 ++ .../xlf/FSharp.Editor.zh-Hant.xlf | 5 ++ 16 files changed, 115 insertions(+) create mode 100644 vsintegration/src/FSharp.Editor/CodeFix/ConvertToSingleEqualsEqualityExpression.fs diff --git a/vsintegration/src/FSharp.Editor/CodeFix/ConvertToSingleEqualsEqualityExpression.fs b/vsintegration/src/FSharp.Editor/CodeFix/ConvertToSingleEqualsEqualityExpression.fs new file mode 100644 index 00000000000..e87538d1b88 --- /dev/null +++ b/vsintegration/src/FSharp.Editor/CodeFix/ConvertToSingleEqualsEqualityExpression.fs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Microsoft.VisualStudio.FSharp.Editor + +open System.Composition +open System.Threading +open System.Threading.Tasks + +open Microsoft.CodeAnalysis.Text +open Microsoft.CodeAnalysis.CodeFixes +open Microsoft.CodeAnalysis.CodeActions + +[] +type internal FSharpConvertToSingleEqualsEqualityExpressionCodeFixProvider() = + inherit CodeFixProvider() + + let fixableDiagnosticIds = set ["FS0043"] + + override __.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds + + override this.RegisterCodeFixesAsync context : Task = + asyncMaybe { + let! sourceText = context.Document.GetTextAsync(context.CancellationToken) + let text = sourceText.GetSubText(context.Span).ToString() + + // We're converting '==' into '=', a common new user mistake. + // If this is an FS00043 that is anything other than that, bail out + do! Option.guard (text = "==") + + let title = SR.ConvertToSingleEqualsEqualityExpression() + + let diagnostics = + context.Diagnostics + |> Seq.filter (fun x -> fixableDiagnosticIds |> Set.contains x.Id) + |> Seq.toImmutableArray + + let codeFix = + CodeFixHelpers.createTextChangeCodeFix( + title, + context, + (fun () -> asyncMaybe.Return [| TextChange(context.Span, "=") |])) + + context.RegisterCodeFix(codeFix, diagnostics) + } + |> Async.Ignore + |> RoslynHelpers.StartAsyncUnitAsTask(context.CancellationToken) \ No newline at end of file diff --git a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj index 8bc59c35a19..dbc0532578e 100644 --- a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj +++ b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj @@ -89,6 +89,7 @@ + diff --git a/vsintegration/src/FSharp.Editor/FSharp.Editor.resx b/vsintegration/src/FSharp.Editor/FSharp.Editor.resx index 8440136cf33..f6fe65527d3 100644 --- a/vsintegration/src/FSharp.Editor/FSharp.Editor.resx +++ b/vsintegration/src/FSharp.Editor/FSharp.Editor.resx @@ -219,4 +219,7 @@ F# Dispostable Values (top-level) + + Use '=' for quality check + \ No newline at end of file diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf index acac2c13bf4..efff6dbd93f 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf @@ -7,6 +7,11 @@ Přidejte klíčové slovo new. + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf index 639a34858b9..3f921469d82 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf @@ -7,6 +7,11 @@ Schlüsselwort "new" hinzufügen + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf index 5f1297eab36..ee34f19a704 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf @@ -7,6 +7,11 @@ Agregar "nueva" palabra clave + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf index 3ae9d25817a..30113aec544 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf @@ -7,6 +7,11 @@ Ajouter le mot clé 'new' + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf index 8457ca172b1..ec46b8054ba 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf @@ -7,6 +7,11 @@ Aggiungi la parola chiave 'new' + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf index 614fdea4a51..46086a1d094 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf @@ -7,6 +7,11 @@ 'new' キーワードを追加する + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf index 832aaa80b5c..34462e785e1 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf @@ -7,6 +7,11 @@ 'new' 키워드 추가 + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf index 785230a56bb..bb045d1e0b3 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf @@ -7,6 +7,11 @@ Dodaj słowo kluczowe „new” + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf index 98636e84fd4..df19ae82250 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf @@ -7,6 +7,11 @@ Adicionar a palavra-chave 'new' + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf index 04891b9acea..2f98e136bef 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf @@ -7,6 +7,11 @@ Добавить ключевое слово "new" + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf index 0cbe170c6d7..3e0a8f3d7c1 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf @@ -7,6 +7,11 @@ 'new' anahtar sözcüğünü ekleme + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf index dd827dbfd65..6f92ec93c04 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf @@ -7,6 +7,11 @@ 添加“新”关键字 + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf index a59aa79970f..6759f8c6035 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf @@ -7,6 +7,11 @@ 新增 'new' 關鍵字 + + Use '=' for quality check + Use '=' for quality check + + F# Disposable Values (locals) F# Disposable Values (locals) From cbda10d081579db38dd4096d1b6616676cd97414 Mon Sep 17 00:00:00 2001 From: cartermp Date: Sun, 15 Nov 2020 16:53:38 -0800 Subject: [PATCH 2/2] Fix type --- vsintegration/src/FSharp.Editor/FSharp.Editor.resx | 2 +- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf | 4 ++-- vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf | 4 ++-- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/vsintegration/src/FSharp.Editor/FSharp.Editor.resx b/vsintegration/src/FSharp.Editor/FSharp.Editor.resx index f6fe65527d3..ec788f3a9d6 100644 --- a/vsintegration/src/FSharp.Editor/FSharp.Editor.resx +++ b/vsintegration/src/FSharp.Editor/FSharp.Editor.resx @@ -220,6 +220,6 @@ F# Dispostable Values (top-level) - Use '=' for quality check + Use '=' for equality check \ No newline at end of file diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf index efff6dbd93f..f37e89003ee 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf index 3f921469d82..699b1abff01 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf index ee34f19a704..fe52d2e336b 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf index 30113aec544..57e84e8a93e 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf index ec46b8054ba..ef5dfd2ab2d 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf index 46086a1d094..ed9ac3084e3 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf index 34462e785e1..834b65325f4 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf index bb045d1e0b3..190c5cc33fc 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf index df19ae82250..ac9a9921316 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf index 2f98e136bef..86e000f34bd 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf index 3e0a8f3d7c1..95c15d15b43 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf index 6f92ec93c04..655d9bb4751 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf index 6759f8c6035..67f5faef874 100644 --- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf +++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf @@ -8,8 +8,8 @@ - Use '=' for quality check - Use '=' for quality check + Use '=' for equality check + Use '=' for equality check