diff --git a/src/Analyzers/CSharp/Analyzers/CodeStyle/CSharpAnalyzerOptionsProvider.cs b/src/Analyzers/CSharp/Analyzers/CodeStyle/CSharpAnalyzerOptionsProvider.cs index 2986950adf1c0..0db8ef09cc3eb 100644 --- a/src/Analyzers/CSharp/Analyzers/CodeStyle/CSharpAnalyzerOptionsProvider.cs +++ b/src/Analyzers/CSharp/Analyzers/CodeStyle/CSharpAnalyzerOptionsProvider.cs @@ -16,7 +16,14 @@ namespace Microsoft.CodeAnalysis.Diagnostics; /// internal readonly struct CSharpAnalyzerOptionsProvider { + /// + /// Document editorconfig options. + /// private readonly AnalyzerConfigOptions _options; + + /// + /// Fallback options - the default options in Code Style layer. + /// private readonly IdeAnalyzerOptions _fallbackOptions; public CSharpAnalyzerOptionsProvider(AnalyzerConfigOptions options, IdeAnalyzerOptions fallbackOptions) @@ -80,13 +87,8 @@ private TValue GetOption(Option2 option, TValue defaultValue) private CSharpIdeCodeStyleOptions FallbackCodeStyleOptions => (CSharpIdeCodeStyleOptions?)_fallbackOptions.CodeStyleOptions ?? CSharpIdeCodeStyleOptions.Default; -#if CODE_STYLE - private static CSharpSimplifierOptions FallbackSimplifierOptions - => CSharpSimplifierOptions.Default; -#else private CSharpSimplifierOptions FallbackSimplifierOptions => (CSharpSimplifierOptions?)_fallbackOptions.CleanupOptions?.SimplifierOptions ?? CSharpSimplifierOptions.Default; -#endif public static explicit operator CSharpAnalyzerOptionsProvider(AnalyzerOptionsProvider provider) => new(provider.GetAnalyzerConfigOptions(), provider.GetFallbackOptions()); diff --git a/src/Analyzers/VisualBasic/Analyzers/CodeStyle/VisualBasicAnalyzerOptionsProvider.vb b/src/Analyzers/VisualBasic/Analyzers/CodeStyle/VisualBasicAnalyzerOptionsProvider.vb index 1dfe84963cd24..2364e44309a77 100644 --- a/src/Analyzers/VisualBasic/Analyzers/CodeStyle/VisualBasicAnalyzerOptionsProvider.vb +++ b/src/Analyzers/VisualBasic/Analyzers/CodeStyle/VisualBasicAnalyzerOptionsProvider.vb @@ -12,7 +12,14 @@ Namespace Microsoft.CodeAnalysis.Diagnostics ''' Provides convenient access to Visual Basic editorconfig options with fallback to IDE default values. ''' Friend Structure VisualBasicAnalyzerOptionsProvider + ''' + ''' Document editorconfig options. + ''' Private ReadOnly _options As AnalyzerConfigOptions + + ''' + ''' Fallback options - the default options in Code Style layer. + ''' Private ReadOnly _fallbackOptions As IdeAnalyzerOptions Public Sub New(options As AnalyzerConfigOptions, fallbackOptions As IdeAnalyzerOptions) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Diagnostics/AnalyzerOptionsProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Diagnostics/AnalyzerOptionsProvider.cs index 5e338c070640a..bcf32cd161b79 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Diagnostics/AnalyzerOptionsProvider.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Diagnostics/AnalyzerOptionsProvider.cs @@ -19,7 +19,14 @@ namespace Microsoft.CodeAnalysis.Diagnostics; /// internal readonly struct AnalyzerOptionsProvider { + /// + /// Document editorconfig options. + /// private readonly AnalyzerConfigOptions _options; + + /// + /// Fallback options - the default options in Code Style layer. + /// private readonly IdeAnalyzerOptions _fallbackOptions; public AnalyzerOptionsProvider(AnalyzerConfigOptions options, IdeAnalyzerOptions fallbackOptions) @@ -83,13 +90,8 @@ private TValue GetOption(PerLanguageOption2 option, TValue defau private IdeCodeStyleOptions.CommonOptions FallbackCodeStyleOptions => _fallbackOptions.CodeStyleOptions?.Common ?? IdeCodeStyleOptions.CommonOptions.Default; -#if CODE_STYLE - private static SimplifierOptions.CommonOptions FallbackSimplifierOptions - => SimplifierOptions.CommonOptions.Default; -#else private SimplifierOptions.CommonOptions FallbackSimplifierOptions => _fallbackOptions.CleanupOptions?.SimplifierOptions.Common ?? SimplifierOptions.CommonOptions.Default; -#endif internal AnalyzerConfigOptions GetAnalyzerConfigOptions() => _options; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Formatting/SyntaxFormattingOptionsProviders.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Formatting/SyntaxFormattingOptionsProviders.cs index aac0d045439b1..0341521cc2c4a 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Formatting/SyntaxFormattingOptionsProviders.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Formatting/SyntaxFormattingOptionsProviders.cs @@ -24,7 +24,9 @@ internal static async ValueTask GetSyntaxFormattingOpti } #if CODE_STYLE +#pragma warning disable IDE0060 // Fallback options currently unused in code style fixers public static async ValueTask GetLineFormattingOptionsAsync(this Document document, LineFormattingOptionsProvider fallbackOptionsProvider, CancellationToken cancellationToken) +#pragma warning restore { var syntaxTree = await document.GetRequiredSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); return LineFormattingOptions.Create(document.Project.AnalyzerOptions.AnalyzerConfigOptionsProvider.GetOptions(syntaxTree), fallbackOptions: null);