diff --git a/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs index 96f448b314839..328dbf1ae6e8d 100644 --- a/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs +++ b/src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs @@ -10,7 +10,6 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Threading; -using Microsoft.CodeAnalysis.CodeQuality; using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.LanguageService; @@ -27,10 +26,9 @@ internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer< TIdentifierNameSyntax, TTypeDeclarationSyntax, TMemberDeclarationSyntax>() - : AbstractCodeQualityDiagnosticAnalyzer( + : AbstractBuiltInUnnecessaryCodeStyleDiagnosticAnalyzer( [s_removeUnusedMembersRule, s_removeUnreadMembersRule], - // We want to analyze references in generated code, but not report unused members in generated code. - GeneratedCodeAnalysisFlags.Analyze) + FadingOptions.FadeOutUnusedMembers) where TDocumentationCommentTriviaSyntax : SyntaxNode where TIdentifierNameSyntax : SyntaxNode where TTypeDeclarationSyntax : TMemberDeclarationSyntax @@ -44,21 +42,23 @@ internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer< memberOptions: SymbolDisplayMemberOptions.IncludeContainingType); // IDE0051: "Remove unused members" (Symbol is declared but never referenced) - private static readonly DiagnosticDescriptor s_removeUnusedMembersRule = CreateDescriptor( + private static readonly DiagnosticDescriptor s_removeUnusedMembersRule = CreateDescriptorWithId( IDEDiagnosticIds.RemoveUnusedMembersDiagnosticId, EnforceOnBuildValues.RemoveUnusedMembers, + hasAnyCodeStyleOption: false, new LocalizableResourceString(nameof(AnalyzersResources.Remove_unused_private_members), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)), new LocalizableResourceString(nameof(AnalyzersResources.Private_member_0_is_unused), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)), - hasAnyCodeStyleOption: false, isUnnecessary: true); + isUnnecessary: true); // IDE0052: "Remove unread members" (Value is written and/or symbol is referenced, but the assigned value is never read) // Internal for testing - internal static readonly DiagnosticDescriptor s_removeUnreadMembersRule = CreateDescriptor( + internal static readonly DiagnosticDescriptor s_removeUnreadMembersRule = CreateDescriptorWithId( IDEDiagnosticIds.RemoveUnreadMembersDiagnosticId, EnforceOnBuildValues.RemoveUnreadMembers, + hasAnyCodeStyleOption: false, new LocalizableResourceString(nameof(AnalyzersResources.Remove_unread_private_members), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)), new LocalizableResourceString(nameof(AnalyzersResources.Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)), - hasAnyCodeStyleOption: false, isUnnecessary: true); + isUnnecessary: true); protected abstract ISemanticFacts SemanticFacts { get; } @@ -66,13 +66,19 @@ internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer< protected abstract SyntaxList GetMembers(TTypeDeclarationSyntax typeDeclaration); protected abstract SyntaxNode GetParentIfSoleDeclarator(SyntaxNode declaration); - // We need to analyze the whole document even for edits within a method body, - // because we might add or remove references to members in executable code. - // For example, if we had an unused field with no references, then editing any single method body - // to reference this field should clear the unused field diagnostic. - // Hence, we need to re-analyze the declarations in the whole file for any edits within the document. + /// + /// We need to analyze the whole document even for edits within a method body, because we might add or remove + /// references to members in executable code. For example, if we had an unused field with no references, then + /// editing any single method body to reference this field should clear the unused field diagnostic. Hence, we need + /// to re-analyze the declarations in the whole file for any edits within the document. + /// public override DiagnosticAnalyzerCategory GetAnalyzerCategory() => DiagnosticAnalyzerCategory.SemanticDocumentAnalysis; + /// + /// We want to analyze references in generated code, but not report unused members in generated code. + /// + protected override GeneratedCodeAnalysisFlags GeneratedCodeAnalysisFlags => GeneratedCodeAnalysisFlags.Analyze; + protected sealed override void InitializeWorker(AnalysisContext context) => context.RegisterCompilationStartAction(compilationStartContext => CompilationAnalyzer.CreateAndRegisterActions(compilationStartContext, this)); diff --git a/src/Analyzers/VisualBasic/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.vb b/src/Analyzers/VisualBasic/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.vb index ae320e02f72bc..994e373f4bab7 100644 --- a/src/Analyzers/VisualBasic/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.vb +++ b/src/Analyzers/VisualBasic/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.vb @@ -1621,7 +1621,7 @@ parseOptions:=Nothing, compilationOptions:=Nothing, options:=Nothing, "IDE0051", -DiagnosticSeverity.Info, +DiagnosticSeverity.Hidden, diagnosticMessage:=String.Format(AnalyzersResources.Private_member_0_is_unused, "C.New")) End Function End Class diff --git a/src/EditorFeatures/CSharpTest/QuickInfo/DiagnosticAnalyzerQuickInfoSourceTests.cs b/src/EditorFeatures/CSharpTest/QuickInfo/DiagnosticAnalyzerQuickInfoSourceTests.cs index 983b7fa7327c6..340b3dd5292e9 100644 --- a/src/EditorFeatures/CSharpTest/QuickInfo/DiagnosticAnalyzerQuickInfoSourceTests.cs +++ b/src/EditorFeatures/CSharpTest/QuickInfo/DiagnosticAnalyzerQuickInfoSourceTests.cs @@ -25,7 +25,7 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.QuickInfo; [UseExportProvider] [Trait(Traits.Feature, Traits.Features.QuickInfo)] -public class DiagnosticAnalyzerQuickInfoSourceTests +public sealed class DiagnosticAnalyzerQuickInfoSourceTests { [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/46604")] public async Task ErrorTitleIsShownOnDisablePragma() @@ -156,26 +156,26 @@ public async Task QuickInfoSuppressMessageAttributeUseCases(string suppressMessa ? GetFormattedIDEAnalyzerTitle(51, nameof(AnalyzersResources.Remove_unused_private_members)) : null; await TestAsync( -@$" -using System.Diagnostics.CodeAnalysis; -using SM = System.Diagnostics.CodeAnalysis.SuppressMessageAttribute; -namespace T -{{ - public static class DiagnosticIds - {{ - public const string IDE0051 = ""IDE0051""; - }} + $$""" + using System.Diagnostics.CodeAnalysis; + using SM = System.Diagnostics.CodeAnalysis.SuppressMessageAttribute; + namespace T + { + public static class DiagnosticIds + { + public const string IDE0051 = "IDE0051"; + } - {suppressMessageAttribute} - public class C - {{ - private int _i; - }} -}} -", description, ImmutableArray.Empty); + {{suppressMessageAttribute}} + public class C + { + private int _i; + } + } + """, description, ImmutableArray.Empty); } - protected static async Task AssertContentIsAsync(EditorTestWorkspace workspace, Document document, int position, string expectedDescription, + private static async Task AssertContentIsAsync(EditorTestWorkspace workspace, Document document, int position, string expectedDescription, ImmutableArray relatedSpans) { var info = await GetQuickinfo(workspace, document, position); @@ -194,13 +194,13 @@ private static async Task GetQuickinfo(EditorTestWorkspace worksp return info; } - protected static async Task AssertNoContentAsync(EditorTestWorkspace workspace, Document document, int position) + private static async Task AssertNoContentAsync(EditorTestWorkspace workspace, Document document, int position) { var info = await GetQuickinfo(workspace, document, position); Assert.Null(info); } - protected static async Task TestAsync( + private static async Task TestAsync( string code, string expectedDescription, ImmutableArray relatedSpans, @@ -237,7 +237,7 @@ private static string GetFormattedIDEAnalyzerTitle(int ideDiagnosticId, string n return $"IDE{ideDiagnosticId:0000}: {localizable}"; } - protected static Task TestInClassAsync(string code, string expectedDescription, params TextSpan[] relatedSpans) + private static Task TestInClassAsync(string code, string expectedDescription, params TextSpan[] relatedSpans) => TestAsync( $$""" class C @@ -246,7 +246,7 @@ class C } """, expectedDescription, relatedSpans.ToImmutableArray()); - protected static Task TestInMethodAsync(string code, string expectedDescription, params TextSpan[] relatedSpans) + private static Task TestInMethodAsync(string code, string expectedDescription, params TextSpan[] relatedSpans) => TestInClassAsync( $$""" void M() diff --git a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml index 02e7d7fdc2ad5..8ef4c9be0c53c 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml +++ b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml @@ -194,6 +194,8 @@ + diff --git a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs index 58390d51eb244..4b2884545023b 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs +++ b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs @@ -129,6 +129,7 @@ public AdvancedOptionPageControl(OptionStore optionStore) : base(optionStore) // Fading BindToOption(Fade_out_unused_usings, FadingOptions.FadeOutUnusedImports, LanguageNames.CSharp); + BindToOption(Fade_out_unused_members, FadingOptions.FadeOutUnusedMembers, LanguageNames.CSharp); BindToOption(Fade_out_unreachable_code, FadingOptions.FadeOutUnreachableCode, LanguageNames.CSharp); // Block Structure Guides diff --git a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageStrings.cs b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageStrings.cs index d100286208751..697627e5c57b5 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageStrings.cs +++ b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageStrings.cs @@ -268,6 +268,9 @@ public static string Option_Fading public static string Option_Fade_out_unused_usings => CSharpVSResources.Fade_out_unused_usings; + public static string Option_Fade_out_unused_members + => ServicesVSResources.Fade_out_unused_members; + public static string Option_Fade_out_unreachable_code => ServicesVSResources.Fade_out_unreachable_code; diff --git a/src/VisualStudio/CSharp/Impl/Options/AutomationObject/AutomationObject.Fading.cs b/src/VisualStudio/CSharp/Impl/Options/AutomationObject/AutomationObject.Fading.cs index 4bc88fcb88ff4..bf8721627a36e 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AutomationObject/AutomationObject.Fading.cs +++ b/src/VisualStudio/CSharp/Impl/Options/AutomationObject/AutomationObject.Fading.cs @@ -4,20 +4,25 @@ using Microsoft.CodeAnalysis.CodeStyle; -namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options +namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options; + +public partial class AutomationObject { - public partial class AutomationObject + public int Fading_FadeOutUnreachableCode + { + get { return GetBooleanOption(FadingOptions.FadeOutUnreachableCode); } + set { SetBooleanOption(FadingOptions.FadeOutUnreachableCode, value); } + } + + public int Fading_FadeOutUnusedImports { - public int Fading_FadeOutUnreachableCode - { - get { return GetBooleanOption(FadingOptions.FadeOutUnreachableCode); } - set { SetBooleanOption(FadingOptions.FadeOutUnreachableCode, value); } - } + get { return GetBooleanOption(FadingOptions.FadeOutUnusedImports); } + set { SetBooleanOption(FadingOptions.FadeOutUnusedImports, value); } + } - public int Fading_FadeOutUnusedImports - { - get { return GetBooleanOption(FadingOptions.FadeOutUnusedImports); } - set { SetBooleanOption(FadingOptions.FadeOutUnusedImports, value); } - } + public int Fading_FadeOutUnusedMembers + { + get { return GetBooleanOption(FadingOptions.FadeOutUnusedMembers); } + set { SetBooleanOption(FadingOptions.FadeOutUnusedMembers, value); } } } diff --git a/src/VisualStudio/CSharp/Impl/Options/AutomationObject/AutomationObject.cs b/src/VisualStudio/CSharp/Impl/Options/AutomationObject/AutomationObject.cs index 4320c664485ad..e9e2a3c5e5281 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AutomationObject/AutomationObject.cs +++ b/src/VisualStudio/CSharp/Impl/Options/AutomationObject/AutomationObject.cs @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options { [ComVisible(true)] - public partial class AutomationObject : AbstractAutomationObject + public sealed partial class AutomationObject : AbstractAutomationObject { internal AutomationObject(ILegacyGlobalOptionService legacyGlobalOptions) : base(legacyGlobalOptions, LanguageNames.CSharp) diff --git a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs index 5759847f9b1a7..34268711400e8 100644 --- a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs +++ b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs @@ -280,6 +280,7 @@ public bool TryFetch(LocalUserRegistryOptionPersister persister, OptionKey2 opti {"dotnet_allow_best_effort_when_extracting_method", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.Allow Best Effort")}, {"dotnet_fade_out_unreachable_code", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.FadeOutUnreachableCode")}, {"dotnet_fade_out_unused_imports", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.FadeOutUnusedImports")}, + {"dotnet_fade_out_unused_members", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.FadeOutUnusedMembers")}, {"dotnet_add_imports_on_paste", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.AddImportsOnPaste2")}, {"dotnet_always_use_default_symbol_servers", new RoamingProfileStorage("TextEditor.AlwaysUseDefaultSymbolServers")}, {"csharp_insert_block_comment_start_string", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.Auto Insert Block Comment Start String")}, diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index 1e64b619eff39..f1767b95414c3 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -763,6 +763,9 @@ Additional information: {1} Analysis + + Fade out unused members + Fade out unreachable code diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf index 0018c4444143e..c4814e44863b7 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -472,6 +472,11 @@ Extrahovat základní Record {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish Dokončit diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index c67415f79e122..b48e3161aeccd 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -472,6 +472,11 @@ Base Record extrahieren {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish Beenden diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index d7a365f5a4bea..964e131a3bd33 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -472,6 +472,11 @@ Extraer Record base {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish Finalizar diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index 06248745a2432..e6439743108f6 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -472,6 +472,11 @@ Extraire le Record de base {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish Terminer diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index aabda29bb7313..a3260a5d30972 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -472,6 +472,11 @@ Estrai Record di base {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish Fine diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index 0c40cbf6242da..24f5d64c25f6c 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -472,6 +472,11 @@ 基底 Record の抽出 {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish 終了 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index 1a4a025ee9bae..f79fc5ac55854 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -472,6 +472,11 @@ 기본 Record 추출 {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish 마침 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index e37e31f4f773f..16a4b9564eb4f 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -472,6 +472,11 @@ Wyodrębnij Record Podstawowy {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish Zakończ diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index fc676afe710c1..0cff23b7b0fca 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -472,6 +472,11 @@ Extrair Record Base {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish Concluir diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index d1567c5a71846..f77ea14538a92 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -472,6 +472,11 @@ Извлечь базовый объект Record {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish Готово diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index 9a8551d21a3dc..55b61d4fd5628 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -472,6 +472,11 @@ Temel Record Öğesini Ayıkla {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish Son diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index ea8ced5280557..2a372ebadcd26 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -472,6 +472,11 @@ 提取基本 Record {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish 完成 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index eeefe118181bf..97bfb165dd9be 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -472,6 +472,11 @@ 擷取基底 Record {Locked="Record"} "Record" is a language construct for C# and should not be localized + + Fade out unused members + Fade out unused members + + Finish 完成 diff --git a/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml b/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml index 61e78dd59057b..6daae1a3a70a5 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml +++ b/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml @@ -181,6 +181,8 @@ + diff --git a/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml.vb b/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml.vb index 36d2e9817111d..c989627195069 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml.vb @@ -129,6 +129,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options ' Fading BindToOption(Fade_out_unused_imports, FadingOptions.FadeOutUnusedImports, LanguageNames.VisualBasic) + BindToOption(Fade_out_unused_members, FadingOptions.FadeOutUnusedMembers, LanguageNames.VisualBasic) ' Block structure guides BindToOption(Show_guides_for_declaration_level_constructs, BlockStructureOptionsStorage.ShowBlockStructureGuidesForDeclarationLevelConstructs, LanguageNames.VisualBasic) diff --git a/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageStrings.vb b/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageStrings.vb index 33d0c1c891bbe..c9b1279055b99 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageStrings.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageStrings.vb @@ -253,6 +253,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options Public ReadOnly Property Option_Fade_out_unused_imports As String = BasicVSResources.Fade_out_unused_imports + Public ReadOnly Property Option_Fade_out_unused_members As String = + ServicesVSResources.Fade_out_unused_members + Public ReadOnly Property Option_Performance As String = ServicesVSResources.Performance diff --git a/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject/AutomationObject.Fading.vb b/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject/AutomationObject.Fading.vb index 7e7c76af9158d..d0e2e0d61a433 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject/AutomationObject.Fading.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject/AutomationObject.Fading.vb @@ -23,5 +23,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options SetBooleanOption(FadingOptions.FadeOutUnusedImports, value) End Set End Property + + Public Property Fading_FadeOutUnusedMembers As Boolean + Get + Return GetBooleanOption(FadingOptions.FadeOutUnusedMembers) + End Get + Set(value As Boolean) + SetBooleanOption(FadingOptions.FadeOutUnusedMembers, value) + End Set + End Property End Class End Namespace diff --git a/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject/AutomationObject.vb b/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject/AutomationObject.vb index 9707be51d9ce8..77ae151d38dbb 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject/AutomationObject.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject/AutomationObject.vb @@ -9,7 +9,7 @@ Imports Microsoft.VisualStudio.LanguageServices.Implementation.Options Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options - Partial Public Class AutomationObject + Partial Public NotInheritable Class AutomationObject Inherits AbstractAutomationObject Friend Sub New(legacyGlobalOptions As ILegacyGlobalOptionService) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/FadingOptions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/FadingOptions.cs index 7028792d88af3..0a4cd95db9c33 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/FadingOptions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CodeStyle/FadingOptions.cs @@ -10,5 +10,6 @@ namespace Microsoft.CodeAnalysis.CodeStyle; internal static class FadingOptions { public static readonly PerLanguageOption2 FadeOutUnusedImports = new("dotnet_fade_out_unused_imports", defaultValue: true); + public static readonly PerLanguageOption2 FadeOutUnusedMembers = new("dotnet_fade_out_unused_members", defaultValue: true); public static readonly PerLanguageOption2 FadeOutUnreachableCode = new("dotnet_fade_out_unreachable_code", defaultValue: true); }