diff --git a/vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs b/vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs index 48e547ab713..f0d3c8f3003 100644 --- a/vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs +++ b/vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs @@ -47,6 +47,9 @@ type internal FSharpRenameUnusedValueCodeFixProvider override __.RegisterCodeFixesAsync context : Task = asyncMaybe { + // Don't show code fixes for unused values, even if they are compiler-generated. + do! Option.guard Settings.CodeFixes.UnusedDeclarations + let document = context.Document let! sourceText = document.GetTextAsync() let ident = sourceText.ToString(context.Span) diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs index 071f0aadbe1..8eb4a1e6d10 100644 --- a/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs +++ b/vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs @@ -100,6 +100,8 @@ type internal UnusedDeclarationsAnalyzer() = override __.AnalyzeSemanticsAsync(document, cancellationToken) = asyncMaybe { + do! Option.guard Settings.CodeFixes.UnusedDeclarations + do Trace.TraceInformation("{0:n3} (start) UnusedDeclarationsAnalyzer", DateTime.Now.TimeOfDay.TotalSeconds) do! Async.Sleep DefaultTuning.UnusedDeclarationsAnalyzerInitialDelay |> liftAsync // be less intrusive, give other work priority most of the time match getProjectInfoManager(document).TryGetOptionsForEditingDocumentOrProject(document) with diff --git a/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs b/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs index 0f4409a99d1..387b808b717 100644 --- a/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs +++ b/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs @@ -34,7 +34,8 @@ type QuickInfoOptions = type CodeFixesOptions = { SimplifyName: bool AlwaysPlaceOpensAtTopLevel: bool - UnusedOpens: bool } + UnusedOpens: bool + UnusedDeclarations: bool } [] type LanguageServicePerformanceOptions = @@ -59,7 +60,8 @@ type internal Settings [](store: SettingsStore) = // See https://github.com/Microsoft/visualfsharp/pull/3238#issue-237699595 SimplifyName = false AlwaysPlaceOpensAtTopLevel = false - UnusedOpens = true } + UnusedOpens = true + UnusedDeclarations = true } store.RegisterDefault { EnableInMemoryCrossProjectReferences = true diff --git a/vsintegration/src/FSharp.UIResources/CodeFixesOptionControl.xaml b/vsintegration/src/FSharp.UIResources/CodeFixesOptionControl.xaml index d6ba236a1c1..b9e9f428146 100644 --- a/vsintegration/src/FSharp.UIResources/CodeFixesOptionControl.xaml +++ b/vsintegration/src/FSharp.UIResources/CodeFixesOptionControl.xaml @@ -26,6 +26,8 @@ + diff --git a/vsintegration/src/FSharp.UIResources/Strings.Designer.cs b/vsintegration/src/FSharp.UIResources/Strings.Designer.cs index ff02acbe6e1..930363c3ddb 100644 --- a/vsintegration/src/FSharp.UIResources/Strings.Designer.cs +++ b/vsintegration/src/FSharp.UIResources/Strings.Designer.cs @@ -19,7 +19,7 @@ namespace Microsoft.VisualStudio.FSharp.UIResources { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Strings { @@ -195,6 +195,15 @@ public static string Solid_underline { } } + /// + /// Looks up a localized string similar to Analyze and suggest fixes for unused values. + /// + public static string Unused_declaration_code_fix { + get { + return ResourceManager.GetString("Unused_declaration_code_fix", resourceCulture); + } + } + /// /// Looks up a localized string similar to Remove unused open statements. /// diff --git a/vsintegration/src/FSharp.UIResources/Strings.resx b/vsintegration/src/FSharp.UIResources/Strings.resx index 4500bfcc71f..1e485e1734f 100644 --- a/vsintegration/src/FSharp.UIResources/Strings.resx +++ b/vsintegration/src/FSharp.UIResources/Strings.resx @@ -165,4 +165,7 @@ Remove unused open statements + + Analyze and suggest fixes for unused values + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf index 98842eff9b3..8686bfd3145 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf @@ -82,6 +82,11 @@ Odebrat nepoužívané otevřené výkazy + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf index d5bde673d62..bd85e458c3f 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf @@ -82,6 +82,11 @@ Nicht verwendete "open"-Anweisungen entfernen + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.en.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.en.xlf index 29e020c9441..8f182327ec7 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.en.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.en.xlf @@ -82,6 +82,11 @@ Remove unused open statements + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf index 362a0e43273..39e7299db9c 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf @@ -82,6 +82,11 @@ Quitar instrucciones open no usadas + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf index bcf05ee03d9..5d12c20685f 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf @@ -82,6 +82,11 @@ Supprimer les instructions open inutilisées + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf index 507714c2bd3..7e2ccdd74f5 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf @@ -82,6 +82,11 @@ Rimuovi istruzioni OPEN inutilizzate + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf index 450504b6049..cf5cf0ca585 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf @@ -82,6 +82,11 @@ 未使用の Open ステートメントを削除する + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf index 55e8ffe0191..ba5378b0f5b 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf @@ -82,6 +82,11 @@ 사용되지 않는 open 문 제거 + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf index fd038b27301..a684cb17715 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf @@ -82,6 +82,11 @@ Usuń nieużywane otwarte instrukcje + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf index c0315f9326a..a71cba02003 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf @@ -82,6 +82,11 @@ Remover instruções abertas não usadas + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf index ef0567208f7..5eeb24b376c 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf @@ -82,6 +82,11 @@ Удалить неиспользуемые открытые операторы + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf index e9964bee3c6..008bc7e5a61 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf @@ -82,6 +82,11 @@ Kullanılmayan açık deyimleri kaldır + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf index c5cf82ce60e..6f53291cea3 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf @@ -82,6 +82,11 @@ 删除未使用的 open 语句 + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf index 8701a74ac44..17cfd2fb722 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf @@ -82,6 +82,11 @@ 移除未使用的 open 陳述式 + + Analyze and suggest fixes for unused values + Analyze and suggest fixes for unused values + + \ No newline at end of file