From 214365629ce61128e59b9affb16100d966563e3c Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Tue, 10 Mar 2020 11:53:24 -0700 Subject: [PATCH] Move all the IDE (Features layer) analyzer to the new options and code style API --- ...ccessibilityModifiersDiagnosticAnalyzer.cs | 6 ++--- ...harpSimplifyTypeNamesDiagnosticAnalyzer.cs | 4 ++-- ...placedUsingDirectivesDiagnosticAnalyzer.cs | 2 +- .../Helpers/UseExpressionBodyHelper.cs | 2 +- .../Helpers/UseExpressionBodyHelper`1.cs | 5 ++-- ...BodyForLambdaCodeStyleProvider_Analysis.cs | 4 ++-- ...eRangeOperatorDiagnosticAnalyzer.Result.cs | 4 ++-- ...SharpUseRangeOperatorDiagnosticAnalyzer.cs | 2 +- ...UseInferredMemberNameDiagnosticAnalyzer.cs | 4 ++-- ...stAndEqualityOperatorDiagnosticAnalyzer.cs | 4 ++-- .../AbstractParenthesesDiagnosticAnalyzer.cs | 12 +++++----- ...ccessibilityModifiersDiagnosticAnalyzer.cs | 6 ++--- ...actAddFileBannerCodeRefactoringProvider.cs | 2 +- ...ddRequiredParenthesesDiagnosticAnalyzer.cs | 7 +++--- .../Portable/Diagnostics/AnalyzerHelper.cs | 8 +++++-- .../EngineV2/DiagnosticIncrementalAnalyzer.cs | 1 + .../Api/PythiaCompletionProviderBase.cs | 2 +- ...erCodeRefactoringProviderMemberCreation.cs | 6 ++--- .../MakeFieldReadonlyDiagnosticAnalyzer.cs | 6 ++--- .../AbstractOrderModifiersCodeFixProvider.cs | 4 ++-- ...bstractOrderModifiersDiagnosticAnalyzer.cs | 4 ++-- ...eferFrameworkTypeDiagnosticAnalyzerBase.cs | 21 ++++++++--------- ...ctQualifyMemberAccessDiagnosticAnalyzer.cs | 23 ++++++++++--------- ...sDiagnosticAnalyzer.SymbolStartAnalyzer.cs | 2 +- ...edParametersAndValuesDiagnosticAnalyzer.cs | 17 +++++++------- ...SimplifyInterpolationDiagnosticAnalyzer.cs | 4 ++-- ...tractSimplifyThisOrMeDiagnosticAnalyzer.cs | 4 ++-- ...SimplifyTypeNamesDiagnosticAnalyzerBase.cs | 12 +++++----- .../AbstractUseAutoPropertyAnalyzer.cs | 6 ++--- ...UseCoalesceExpressionDiagnosticAnalyzer.cs | 4 ++-- ...ExpressionForNullableDiagnosticAnalyzer.cs | 4 ++-- ...CollectionInitializerDiagnosticAnalyzer.cs | 6 ++--- ...UseCompoundAssignmentDiagnosticAnalyzer.cs | 4 ++-- ...ConditionalExpressionDiagnosticAnalyzer.cs | 4 ++-- ...pressionForAssignmentDiagnosticAnalyzer.cs | 2 +- ...alExpressionForReturnDiagnosticAnalyzer.cs | 2 +- .../UseExplicitTupleNameDiagnosticAnalyzer.cs | 4 ++-- ...UseInferredMemberNameDiagnosticAnalyzer.cs | 2 +- ...ullForReferenceEqualsDiagnosticAnalyzer.cs | 4 ++-- ...actUseNullPropagationDiagnosticAnalyzer.cs | 4 ++-- ...tUseObjectInitializerDiagnosticAnalyzer.cs | 7 +++--- .../UseSystemHashCodeDiagnosticAnalyzer.cs | 4 ++-- ...actUseThrowExpressionDiagnosticAnalyzer.cs | 4 ++-- .../BinaryExpressionCodeActionComputer.cs | 2 +- ...ccessibilityModifiersDiagnosticAnalyzer.vb | 6 ++--- ...asicSimplifyTypeNamesDiagnosticAnalyzer.vb | 4 ++-- ...UseInferredMemberNameDiagnosticAnalyzer.vb | 4 ++-- 47 files changed, 129 insertions(+), 126 deletions(-) diff --git a/src/Features/CSharp/Portable/AddAccessibilityModifiers/CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs b/src/Features/CSharp/Portable/AddAccessibilityModifiers/CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs index c8811e9926796..88e63c71ed93b 100644 --- a/src/Features/CSharp/Portable/AddAccessibilityModifiers/CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs +++ b/src/Features/CSharp/Portable/AddAccessibilityModifiers/CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs @@ -22,14 +22,14 @@ public CSharpAddAccessibilityModifiersDiagnosticAnalyzer() protected override void ProcessCompilationUnit( SyntaxTreeAnalysisContext context, SyntaxGenerator generator, - CodeStyleOption option, CompilationUnitSyntax compilationUnit) + CodeStyleOption2 option, CompilationUnitSyntax compilationUnit) { ProcessMembers(context, generator, option, compilationUnit.Members); } private void ProcessMembers( SyntaxTreeAnalysisContext context, SyntaxGenerator generator, - CodeStyleOption option, + CodeStyleOption2 option, SyntaxList members) { foreach (var memberDeclaration in members) @@ -40,7 +40,7 @@ private void ProcessMembers( private void ProcessMemberDeclaration( SyntaxTreeAnalysisContext context, SyntaxGenerator generator, - CodeStyleOption option, MemberDeclarationSyntax member) + CodeStyleOption2 option, MemberDeclarationSyntax member) { if (member.IsKind(SyntaxKind.NamespaceDeclaration, out NamespaceDeclarationSyntax namespaceDeclaration)) { diff --git a/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs b/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs index 128bb249ee835..4c78b07415c7e 100644 --- a/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs +++ b/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs @@ -124,12 +124,12 @@ internal override bool CanSimplifyTypeNameExpression( } // set proper diagnostic ids. - if (replacementSyntax.HasAnnotations(nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration))) + if (replacementSyntax.HasAnnotations(nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration))) { inDeclaration = true; diagnosticId = IDEDiagnosticIds.PreferBuiltInOrFrameworkTypeDiagnosticId; } - else if (replacementSyntax.HasAnnotations(nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess))) + else if (replacementSyntax.HasAnnotations(nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess))) { inDeclaration = false; diagnosticId = IDEDiagnosticIds.PreferBuiltInOrFrameworkTypeDiagnosticId; diff --git a/src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs b/src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs index f1d16b5ce95d0..7bedd8e6b3783 100644 --- a/src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs +++ b/src/Features/CSharp/Portable/MisplacedUsingDirectives/MisplacedUsingDirectivesDiagnosticAnalyzer.cs @@ -89,7 +89,7 @@ private static bool ShouldSuppressDiagnostic(CompilationUnitSyntax compilationUn private static void ReportDiagnostics( SyntaxNodeAnalysisContext context, DiagnosticDescriptor descriptor, - IEnumerable usingDirectives, CodeStyleOption option) + IEnumerable usingDirectives, CodeStyleOption2 option) { foreach (var usingDirective in usingDirectives) { diff --git a/src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs b/src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs index d223588704308..928e6e705a31f 100644 --- a/src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs +++ b/src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UseExpressionBody { internal abstract class UseExpressionBodyHelper { - public abstract Option> Option { get; } + public abstract Option2> Option { get; } public abstract LocalizableString UseExpressionBodyTitle { get; } public abstract LocalizableString UseBlockBodyTitle { get; } public abstract string DiagnosticId { get; } diff --git a/src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper`1.cs b/src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper`1.cs index 611f27dd09fd9..7d13d6f3546f8 100644 --- a/src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper`1.cs +++ b/src/Features/CSharp/Portable/UseExpressionBody/Helpers/UseExpressionBodyHelper`1.cs @@ -22,7 +22,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UseExpressionBody internal abstract class UseExpressionBodyHelper : UseExpressionBodyHelper where TDeclaration : SyntaxNode { - public override Option> Option { get; } + public override Option2> Option { get; } public override LocalizableString UseExpressionBodyTitle { get; } public override LocalizableString UseBlockBodyTitle { get; } public override string DiagnosticId { get; } @@ -32,7 +32,7 @@ protected UseExpressionBodyHelper( string diagnosticId, LocalizableString useExpressionBodyTitle, LocalizableString useBlockBodyTitle, - Option> option, + Option2> option, ImmutableArray syntaxKinds) { DiagnosticId = diagnosticId; @@ -55,7 +55,6 @@ protected static AccessorDeclarationSyntax GetSingleGetAccessor(AccessorListSynt return null; } - protected static BlockSyntax GetBodyFromSingleGetAccessor(AccessorListSyntax accessorList) => GetSingleGetAccessor(accessorList)?.Body; diff --git a/src/Features/CSharp/Portable/UseExpressionBodyForLambda/UseExpressionBodyForLambdaCodeStyleProvider_Analysis.cs b/src/Features/CSharp/Portable/UseExpressionBodyForLambda/UseExpressionBodyForLambdaCodeStyleProvider_Analysis.cs index 021da049af014..04333cf1659c2 100644 --- a/src/Features/CSharp/Portable/UseExpressionBodyForLambda/UseExpressionBodyForLambdaCodeStyleProvider_Analysis.cs +++ b/src/Features/CSharp/Portable/UseExpressionBodyForLambda/UseExpressionBodyForLambdaCodeStyleProvider_Analysis.cs @@ -22,7 +22,7 @@ protected override void DiagnosticAnalyzerInitialize(AnalysisContext context) protected override DiagnosticAnalyzerCategory GetAnalyzerCategory() => DiagnosticAnalyzerCategory.SemanticSpanAnalysis; - private void AnalyzeSyntax(SyntaxNodeAnalysisContext context, CodeStyleOption option) + private void AnalyzeSyntax(SyntaxNodeAnalysisContext context, CodeStyleOption2 option) { var declaration = (LambdaExpressionSyntax)context.Node; var diagnostic = AnalyzeSyntax(context.SemanticModel, option, declaration, context.CancellationToken); @@ -33,7 +33,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context, CodeStyleOption option, + SemanticModel semanticModel, CodeStyleOption2 option, LambdaExpressionSyntax declaration, CancellationToken cancellationToken) { if (CanOfferUseExpressionBody(option.Value, declaration)) diff --git a/src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.Result.cs b/src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.Result.cs index ae998a1dd83ce..babff3a37a7e3 100644 --- a/src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.Result.cs +++ b/src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.Result.cs @@ -22,7 +22,7 @@ public enum ResultKind public readonly struct Result { public readonly ResultKind Kind; - public readonly CodeStyleOption Option; + public readonly CodeStyleOption2 Option; public readonly IInvocationOperation InvocationOperation; public readonly InvocationExpressionSyntax Invocation; public readonly IMethodSymbol SliceLikeMethod; @@ -31,7 +31,7 @@ public readonly struct Result public readonly IOperation Op2; public Result( - ResultKind kind, CodeStyleOption option, + ResultKind kind, CodeStyleOption2 option, IInvocationOperation invocationOperation, InvocationExpressionSyntax invocation, IMethodSymbol sliceLikeMethod, MemberInfo memberInfo, IOperation op1, IOperation op2) diff --git a/src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs b/src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs index 49e9fb402c913..adbd8a5a21027 100644 --- a/src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs +++ b/src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs @@ -92,7 +92,7 @@ private void AnalyzeInvocation( return default; } - CodeStyleOption option = null; + CodeStyleOption2 option = null; if (analyzerOptionsOpt != null) { // Check if we're at least on C# 8, and that the user wants these operators. diff --git a/src/Features/CSharp/Portable/UseInferredMemberName/CSharpUseInferredMemberNameDiagnosticAnalyzer.cs b/src/Features/CSharp/Portable/UseInferredMemberName/CSharpUseInferredMemberNameDiagnosticAnalyzer.cs index 5dfa64471ee42..7f9cf365fe2e1 100644 --- a/src/Features/CSharp/Portable/UseInferredMemberName/CSharpUseInferredMemberNameDiagnosticAnalyzer.cs +++ b/src/Features/CSharp/Portable/UseInferredMemberName/CSharpUseInferredMemberNameDiagnosticAnalyzer.cs @@ -45,7 +45,7 @@ private void ReportDiagnosticsIfNeeded(NameColonSyntax nameColon, SyntaxNodeAnal var parseOptions = (CSharpParseOptions)syntaxTree.Options; var preference = options.GetOption( - CodeStyleOptions.PreferInferredTupleNames, context.Compilation.Language, syntaxTree, cancellationToken); + CodeStyleOptions2.PreferInferredTupleNames, context.Compilation.Language, syntaxTree, cancellationToken); if (!preference.Value || !CSharpInferredMemberNameReducer.CanSimplifyTupleElementName(argument, parseOptions)) { @@ -78,7 +78,7 @@ private void ReportDiagnosticsIfNeeded(NameEqualsSyntax nameEquals, SyntaxNodeAn } var preference = options.GetOption( - CodeStyleOptions.PreferInferredAnonymousTypeMemberNames, context.Compilation.Language, syntaxTree, cancellationToken); + CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames, context.Compilation.Language, syntaxTree, cancellationToken); if (!preference.Value || !CSharpInferredMemberNameReducer.CanSimplifyAnonymousTypeMemberName(anonCtor)) { diff --git a/src/Features/CSharp/Portable/UseIsNullCheck/CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer.cs b/src/Features/CSharp/Portable/UseIsNullCheck/CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer.cs index 93513d23a46f8..d6e7e9bf3d967 100644 --- a/src/Features/CSharp/Portable/UseIsNullCheck/CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer.cs +++ b/src/Features/CSharp/Portable/UseIsNullCheck/CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer.cs @@ -19,7 +19,7 @@ internal class CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer public CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseIsNullCheckDiagnosticId, - CodeStyleOptions.PreferIsNullCheckOverReferenceEqualityMethod, + CodeStyleOptions2.PreferIsNullCheckOverReferenceEqualityMethod, CSharpFeaturesResources.Use_is_null_check, new LocalizableResourceString(nameof(FeaturesResources.Null_check_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -43,7 +43,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context) return; } - var option = context.Options.GetOption(CodeStyleOptions.PreferIsNullCheckOverReferenceEqualityMethod, semanticModel.Language, syntaxTree, cancellationToken); + var option = context.Options.GetOption(CodeStyleOptions2.PreferIsNullCheckOverReferenceEqualityMethod, semanticModel.Language, syntaxTree, cancellationToken); if (!option.Value) { return; diff --git a/src/Features/Core/Portable/AbstractParenthesesDiagnosticAnalyzer.cs b/src/Features/Core/Portable/AbstractParenthesesDiagnosticAnalyzer.cs index 944500efe36ef..44131b2e0e086 100644 --- a/src/Features/Core/Portable/AbstractParenthesesDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/AbstractParenthesesDiagnosticAnalyzer.cs @@ -15,7 +15,7 @@ internal abstract class AbstractParenthesesDiagnosticAnalyzer : AbstractBuiltInC protected AbstractParenthesesDiagnosticAnalyzer( string descriptorId, LocalizableString title, LocalizableString message) : base(descriptorId, - options: ImmutableHashSet.Create(CodeStyleOptions.ArithmeticBinaryParentheses, CodeStyleOptions.RelationalBinaryParentheses, CodeStyleOptions.OtherBinaryParentheses, CodeStyleOptions.OtherParentheses), + options: ImmutableHashSet.Create(CodeStyleOptions2.ArithmeticBinaryParentheses, CodeStyleOptions2.RelationalBinaryParentheses, CodeStyleOptions2.OtherBinaryParentheses, CodeStyleOptions2.OtherParentheses), title, message) { } @@ -25,22 +25,22 @@ protected AbstractParenthesesDiagnosticAnalyzer(ImmutableArray> GetLanguageOption(PrecedenceKind precedenceKind) + protected PerLanguageOption2> GetLanguageOption(PrecedenceKind precedenceKind) { switch (precedenceKind) { case PrecedenceKind.Arithmetic: case PrecedenceKind.Shift: case PrecedenceKind.Bitwise: - return CodeStyleOptions.ArithmeticBinaryParentheses; + return CodeStyleOptions2.ArithmeticBinaryParentheses; case PrecedenceKind.Relational: case PrecedenceKind.Equality: - return CodeStyleOptions.RelationalBinaryParentheses; + return CodeStyleOptions2.RelationalBinaryParentheses; case PrecedenceKind.Logical: case PrecedenceKind.Coalesce: - return CodeStyleOptions.OtherBinaryParentheses; + return CodeStyleOptions2.OtherBinaryParentheses; case PrecedenceKind.Other: - return CodeStyleOptions.OtherParentheses; + return CodeStyleOptions2.OtherParentheses; } throw ExceptionUtilities.UnexpectedValue(precedenceKind); diff --git a/src/Features/Core/Portable/AddAccessibilityModifiers/AbstractAddAccessibilityModifiersDiagnosticAnalyzer.cs b/src/Features/Core/Portable/AddAccessibilityModifiers/AbstractAddAccessibilityModifiersDiagnosticAnalyzer.cs index 9d17a43f4343d..5059bc54ab6b1 100644 --- a/src/Features/Core/Portable/AddAccessibilityModifiers/AbstractAddAccessibilityModifiersDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/AddAccessibilityModifiers/AbstractAddAccessibilityModifiersDiagnosticAnalyzer.cs @@ -14,7 +14,7 @@ internal abstract class AbstractAddAccessibilityModifiersDiagnosticAnalyzer option, TCompilationUnitSyntax compilationUnitSyntax); + protected abstract void ProcessCompilationUnit(SyntaxTreeAnalysisContext context, SyntaxGenerator generator, CodeStyleOption2 option, TCompilationUnitSyntax compilationUnitSyntax); } } diff --git a/src/Features/Core/Portable/AddFileBanner/AbstractAddFileBannerCodeRefactoringProvider.cs b/src/Features/Core/Portable/AddFileBanner/AbstractAddFileBannerCodeRefactoringProvider.cs index 92fac9433969f..fd223bb9f7b27 100644 --- a/src/Features/Core/Portable/AddFileBanner/AbstractAddFileBannerCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/AddFileBanner/AbstractAddFileBannerCodeRefactoringProvider.cs @@ -39,7 +39,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte var tree = await document.GetRequiredSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false); - if (document.Project.AnalyzerOptions.TryGetEditorConfigOption(CodeStyleOptions.FileHeaderTemplate, tree, out string fileHeaderTemplate) + if (document.Project.AnalyzerOptions.TryGetEditorConfigOption(CodeStyleOptions2.FileHeaderTemplate, tree, out string fileHeaderTemplate) && !string.IsNullOrEmpty(fileHeaderTemplate)) { // If we have a defined file header template, allow the analyzer and code fix to handle it diff --git a/src/Features/Core/Portable/AddRequiredParentheses/AbstractAddRequiredParenthesesDiagnosticAnalyzer.cs b/src/Features/Core/Portable/AddRequiredParentheses/AbstractAddRequiredParenthesesDiagnosticAnalyzer.cs index cf9a399df38d0..8f2a0cc6a27fb 100644 --- a/src/Features/Core/Portable/AddRequiredParentheses/AbstractAddRequiredParenthesesDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/AddRequiredParentheses/AbstractAddRequiredParenthesesDiagnosticAnalyzer.cs @@ -9,6 +9,7 @@ using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.LanguageServices; +using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.RemoveUnnecessaryParentheses; namespace Microsoft.CodeAnalysis.AddRequiredParentheses @@ -29,8 +30,8 @@ static AbstractAddRequiredParenthesesDiagnosticAnalyzer() { var options = new[] { - CodeStyleOptions.ArithmeticBinaryParentheses, CodeStyleOptions.OtherBinaryParentheses, - CodeStyleOptions.OtherParentheses, CodeStyleOptions.RelationalBinaryParentheses + CodeStyleOptions2.ArithmeticBinaryParentheses, CodeStyleOptions2.OtherBinaryParentheses, + CodeStyleOptions2.OtherParentheses, CodeStyleOptions2.RelationalBinaryParentheses }; var includeArray = new[] { false, true }; @@ -52,7 +53,7 @@ static AbstractAddRequiredParenthesesDiagnosticAnalyzer() } } - private static string GetEquivalenceKey(Options.PerLanguageOption> parentPrecedence) + private static string GetEquivalenceKey(PerLanguageOption2> parentPrecedence) => parentPrecedence.Name; private static ImmutableDictionary GetProperties(bool includeInFixAll, string equivalenceKey) diff --git a/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs b/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs index 7729b5e03d5d9..a118da9913a3a 100644 --- a/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs +++ b/src/Features/Core/Portable/Diagnostics/AnalyzerHelper.cs @@ -21,6 +21,10 @@ using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; +#if !CODE_STYLE +using OptionSet = Microsoft.CodeAnalysis.Options.OptionSet; +#endif + namespace Microsoft.CodeAnalysis.Diagnostics { internal static partial class AnalyzerHelper @@ -108,12 +112,12 @@ public static async ValueTask GetAnalyzerOptionSetAsync(this Analyzer return new AnalyzerConfigOptionSet(configOptions, optionSet); } - public static T GetOption(this AnalyzerOptions analyzerOptions, Option option, SyntaxTree syntaxTree, CancellationToken cancellationToken) + public static T GetOption(this AnalyzerOptions analyzerOptions, ILanguageSpecificOption option, SyntaxTree syntaxTree, CancellationToken cancellationToken) { return GetOptionAsync(analyzerOptions, option, language: null, syntaxTree, cancellationToken).GetAwaiter().GetResult(); } - public static T GetOption(this AnalyzerOptions analyzerOptions, PerLanguageOption option, string? language, SyntaxTree syntaxTree, CancellationToken cancellationToken) + public static T GetOption(this AnalyzerOptions analyzerOptions, IPerLanguageOption option, string? language, SyntaxTree syntaxTree, CancellationToken cancellationToken) { return GetOptionAsync(analyzerOptions, option, language, syntaxTree, cancellationToken).GetAwaiter().GetResult(); } diff --git a/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.cs b/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.cs index 5675656c3afe4..f6e13db5a5d8f 100644 --- a/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.cs +++ b/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.cs @@ -95,6 +95,7 @@ public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs { return e.Option.Feature == nameof(SimplificationOptions) || e.Option.Feature == nameof(CodeStyleOptions) || + e.Option.Feature == nameof(CodeStyleOptions2) || e.Option == SolutionCrawlerOptions.BackgroundAnalysisScopeOption || #pragma warning disable CS0618 // Type or member is obsolete - TypeScript and F# are still on the older ClosedFileDiagnostic option. e.Option == ServiceFeatureOnOffOptions.ClosedFileDiagnostic; diff --git a/src/Features/Core/Portable/ExternalAccess/Pythia/Api/PythiaCompletionProviderBase.cs b/src/Features/Core/Portable/ExternalAccess/Pythia/Api/PythiaCompletionProviderBase.cs index 19952933e2501..f81fec6dc2b91 100644 --- a/src/Features/Core/Portable/ExternalAccess/Pythia/Api/PythiaCompletionProviderBase.cs +++ b/src/Features/Core/Portable/ExternalAccess/Pythia/Api/PythiaCompletionProviderBase.cs @@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.Pythia.Api { internal abstract class PythiaCompletionProviderBase : CommonCompletionProvider { - public static PerLanguageOption HideAdvancedMembersOption => CompletionOptions.HideAdvancedMembers; + public static PerLanguageOption2 HideAdvancedMembersOption => CompletionOptions.HideAdvancedMembers; public static CompletionItem CreateCommonCompletionItem( string displayText, diff --git a/src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs b/src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs index a5cd2af6820f0..fd14d87804d0a 100644 --- a/src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs +++ b/src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs @@ -98,7 +98,7 @@ protected override async Task> GetRefactoringsForSing var codeGenService = document.GetLanguageService(); var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); - var requireAccessibilityModifiers = options.GetOption(CodeStyleOptions.RequireAccessibilityModifiers); + var requireAccessibilityModifiers = options.GetOption(CodeStyleOptions2.RequireAccessibilityModifiers); var field = CreateField(requireAccessibilityModifiers, parameter, rules, parameterNameParts.BaseNameParts); var property = CreateProperty(requireAccessibilityModifiers, parameter, rules, parameterNameParts.BaseNameParts); @@ -115,7 +115,7 @@ protected override async Task> GetRefactoringsForSing } private IFieldSymbol CreateField( - CodeStyleOption requireAccessibilityModifiers, + CodeStyleOption2 requireAccessibilityModifiers, IParameterSymbol parameter, ImmutableArray rules, ImmutableArray parameterNameParts) @@ -163,7 +163,7 @@ private static string GenerateUniqueName(IParameterSymbol parameter, ImmutableAr } private IPropertySymbol CreateProperty( - CodeStyleOption requireAccessibilityModifiers, + CodeStyleOption2 requireAccessibilityModifiers, IParameterSymbol parameter, ImmutableArray rules, ImmutableArray parameterNameParts) diff --git a/src/Features/Core/Portable/MakeFieldReadonly/MakeFieldReadonlyDiagnosticAnalyzer.cs b/src/Features/Core/Portable/MakeFieldReadonly/MakeFieldReadonlyDiagnosticAnalyzer.cs index d7ba8d9e81c27..3e138e7d6f6e7 100644 --- a/src/Features/Core/Portable/MakeFieldReadonly/MakeFieldReadonlyDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/MakeFieldReadonly/MakeFieldReadonlyDiagnosticAnalyzer.cs @@ -19,7 +19,7 @@ internal sealed class MakeFieldReadonlyDiagnosticAnalyzer public MakeFieldReadonlyDiagnosticAnalyzer() : base( IDEDiagnosticIds.MakeFieldReadonlyDiagnosticId, - CodeStyleOptions.PreferReadonly, + CodeStyleOptions2.PreferReadonly, new LocalizableResourceString(nameof(FeaturesResources.Add_readonly_modifier), FeaturesResources.ResourceManager, typeof(FeaturesResources)), new LocalizableResourceString(nameof(FeaturesResources.Make_field_readonly), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -213,9 +213,9 @@ private static bool IsInAnonymousFunctionOrLocalFunction(IOperation operation) return false; } - private static CodeStyleOption GetCodeStyleOption(IFieldSymbol field, AnalyzerOptions options, CancellationToken cancellationToken) + private static CodeStyleOption2 GetCodeStyleOption(IFieldSymbol field, AnalyzerOptions options, CancellationToken cancellationToken) { - return options.GetOption(CodeStyleOptions.PreferReadonly, field.Language, field.Locations[0].SourceTree, cancellationToken); + return options.GetOption(CodeStyleOptions2.PreferReadonly, field.Language, field.Locations[0].SourceTree, cancellationToken); } } } diff --git a/src/Features/Core/Portable/OrderModifiers/AbstractOrderModifiersCodeFixProvider.cs b/src/Features/Core/Portable/OrderModifiers/AbstractOrderModifiersCodeFixProvider.cs index 12af7cc0ef215..80486894a80ae 100644 --- a/src/Features/Core/Portable/OrderModifiers/AbstractOrderModifiersCodeFixProvider.cs +++ b/src/Features/Core/Portable/OrderModifiers/AbstractOrderModifiersCodeFixProvider.cs @@ -22,12 +22,12 @@ namespace Microsoft.CodeAnalysis.OrderModifiers internal abstract class AbstractOrderModifiersCodeFixProvider : SyntaxEditorBasedCodeFixProvider { private readonly ISyntaxFacts _syntaxFacts; - private readonly Option> _option; + private readonly Option2> _option; private readonly AbstractOrderModifiersHelpers _helpers; protected AbstractOrderModifiersCodeFixProvider( ISyntaxFacts syntaxFacts, - Option> option, + Option2> option, AbstractOrderModifiersHelpers helpers) { _syntaxFacts = syntaxFacts; diff --git a/src/Features/Core/Portable/OrderModifiers/AbstractOrderModifiersDiagnosticAnalyzer.cs b/src/Features/Core/Portable/OrderModifiers/AbstractOrderModifiersDiagnosticAnalyzer.cs index 8741851b9f161..88ab2eda71a16 100644 --- a/src/Features/Core/Portable/OrderModifiers/AbstractOrderModifiersDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/OrderModifiers/AbstractOrderModifiersDiagnosticAnalyzer.cs @@ -14,12 +14,12 @@ namespace Microsoft.CodeAnalysis.OrderModifiers internal abstract class AbstractOrderModifiersDiagnosticAnalyzer : AbstractBuiltInCodeStyleDiagnosticAnalyzer { private readonly ISyntaxFacts _syntaxFacts; - private readonly Option> _option; + private readonly Option2> _option; private readonly AbstractOrderModifiersHelpers _helpers; protected AbstractOrderModifiersDiagnosticAnalyzer( ISyntaxFacts syntaxFacts, - Option> option, + Option2> option, AbstractOrderModifiersHelpers helpers, string language) : base(IDEDiagnosticIds.OrderModifiersDiagnosticId, diff --git a/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeDiagnosticAnalyzerBase.cs b/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeDiagnosticAnalyzerBase.cs index 089d94c3dd692..f95cef09a3b3b 100644 --- a/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeDiagnosticAnalyzerBase.cs +++ b/src/Features/Core/Portable/PreferFrameworkType/PreferFrameworkTypeDiagnosticAnalyzerBase.cs @@ -4,12 +4,11 @@ #nullable enable -using System; using System.Collections.Immutable; -using System.Threading; using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Options; +using OptionSet = Microsoft.CodeAnalysis.Options.OptionSet; namespace Microsoft.CodeAnalysis.PreferFrameworkType { @@ -21,24 +20,24 @@ internal abstract class PreferFrameworkTypeDiagnosticAnalyzerBase(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess), + options: ImmutableHashSet.Create(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess), new LocalizableResourceString(nameof(FeaturesResources.Use_framework_type), FeaturesResources.ResourceManager, typeof(FeaturesResources)), new LocalizableResourceString(nameof(FeaturesResources.Use_framework_type), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { } - private static PerLanguageOption> GetOptionForDeclarationContext - => CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration; + private static PerLanguageOption2> GetOptionForDeclarationContext + => CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration; - private static PerLanguageOption> GetOptionForMemberAccessContext - => CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess; + private static PerLanguageOption2> GetOptionForMemberAccessContext + => CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess; public override bool OpenFileOnly(OptionSet options) { var preferTypeKeywordInDeclarationOption = options.GetOption( - CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, GetLanguageName()).Notification; + CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, GetLanguageName()).Notification; var preferTypeKeywordInMemberAccessOption = options.GetOption( - CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, GetLanguageName()).Notification; + CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, GetLanguageName()).Notification; return !(preferTypeKeywordInDeclarationOption == NotificationOption.Warning || preferTypeKeywordInDeclarationOption == NotificationOption.Error || preferTypeKeywordInMemberAccessOption == NotificationOption.Warning || preferTypeKeywordInMemberAccessOption == NotificationOption.Error); @@ -121,7 +120,7 @@ private bool IsStylePreferred( private bool IsFrameworkTypePreferred( SyntaxNodeAnalysisContext context, - PerLanguageOption> option, + PerLanguageOption2> option, string language) { var optionValue = context.GetOption(option, language); @@ -132,7 +131,7 @@ private bool IsFrameworkTypePreferred( /// checks if style is preferred and the enforcement is not None. /// /// if predefined type is not preferred, it implies the preference is framework type. - private static bool OptionSettingPrefersFrameworkType(CodeStyleOption optionValue, ReportDiagnostic severity) + private static bool OptionSettingPrefersFrameworkType(CodeStyleOption2 optionValue, ReportDiagnostic severity) => !optionValue.Value && severity != ReportDiagnostic.Suppress; } } diff --git a/src/Features/Core/Portable/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs b/src/Features/Core/Portable/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs index 30afe2056c005..a0f164c3a0030 100644 --- a/src/Features/Core/Portable/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs @@ -8,6 +8,7 @@ using Microsoft.CodeAnalysis.Operations; using Microsoft.CodeAnalysis.Options; using Roslyn.Utilities; +using OptionSet = Microsoft.CodeAnalysis.Options.OptionSet; namespace Microsoft.CodeAnalysis.QualifyMemberAccess { @@ -22,7 +23,7 @@ internal abstract class AbstractQualifyMemberAccessDiagnosticAnalyzer< { protected AbstractQualifyMemberAccessDiagnosticAnalyzer() : base(IDEDiagnosticIds.AddQualificationDiagnosticId, - options: ImmutableHashSet.Create(CodeStyleOptions.QualifyFieldAccess, CodeStyleOptions.QualifyPropertyAccess, CodeStyleOptions.QualifyMethodAccess, CodeStyleOptions.QualifyEventAccess), + options: ImmutableHashSet.Create(CodeStyleOptions2.QualifyFieldAccess, CodeStyleOptions2.QualifyPropertyAccess, CodeStyleOptions2.QualifyMethodAccess, CodeStyleOptions2.QualifyEventAccess), new LocalizableResourceString(nameof(WorkspacesResources.Member_access_should_be_qualified), WorkspacesResources.ResourceManager, typeof(WorkspacesResources)), new LocalizableResourceString(nameof(FeaturesResources.Add_this_or_Me_qualification), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -30,10 +31,10 @@ protected AbstractQualifyMemberAccessDiagnosticAnalyzer() public override bool OpenFileOnly(OptionSet options) { - var qualifyFieldAccessOption = options.GetOption(CodeStyleOptions.QualifyFieldAccess, GetLanguageName()).Notification; - var qualifyPropertyAccessOption = options.GetOption(CodeStyleOptions.QualifyPropertyAccess, GetLanguageName()).Notification; - var qualifyMethodAccessOption = options.GetOption(CodeStyleOptions.QualifyMethodAccess, GetLanguageName()).Notification; - var qualifyEventAccessOption = options.GetOption(CodeStyleOptions.QualifyEventAccess, GetLanguageName()).Notification; + var qualifyFieldAccessOption = options.GetOption(CodeStyleOptions2.QualifyFieldAccess, GetLanguageName()).Notification; + var qualifyPropertyAccessOption = options.GetOption(CodeStyleOptions2.QualifyPropertyAccess, GetLanguageName()).Notification; + var qualifyMethodAccessOption = options.GetOption(CodeStyleOptions2.QualifyMethodAccess, GetLanguageName()).Notification; + var qualifyEventAccessOption = options.GetOption(CodeStyleOptions2.QualifyEventAccess, GetLanguageName()).Notification; return !(qualifyFieldAccessOption == NotificationOption.Warning || qualifyFieldAccessOption == NotificationOption.Error || qualifyPropertyAccessOption == NotificationOption.Warning || qualifyPropertyAccessOption == NotificationOption.Error || @@ -168,24 +169,24 @@ static bool IsStaticMemberOrIsLocalFunctionHelper(ISymbol symbol) internal static class QualifyMembersHelpers { - public static PerLanguageOption> GetApplicableOptionFromSymbolKind(SymbolKind symbolKind) + public static PerLanguageOption2> GetApplicableOptionFromSymbolKind(SymbolKind symbolKind) { switch (symbolKind) { case SymbolKind.Field: - return CodeStyleOptions.QualifyFieldAccess; + return CodeStyleOptions2.QualifyFieldAccess; case SymbolKind.Property: - return CodeStyleOptions.QualifyPropertyAccess; + return CodeStyleOptions2.QualifyPropertyAccess; case SymbolKind.Method: - return CodeStyleOptions.QualifyMethodAccess; + return CodeStyleOptions2.QualifyMethodAccess; case SymbolKind.Event: - return CodeStyleOptions.QualifyEventAccess; + return CodeStyleOptions2.QualifyEventAccess; default: throw ExceptionUtilities.UnexpectedValue(symbolKind); } } - internal static PerLanguageOption> GetApplicableOptionFromSymbolKind(IOperation operation) + internal static PerLanguageOption2> GetApplicableOptionFromSymbolKind(IOperation operation) { switch (operation) { diff --git a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs index 770f4f344543e..1a80b0fccde85 100644 --- a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs +++ b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs @@ -130,7 +130,7 @@ private void ReportUnusedParameterDiagnostic( } var location = parameter.Locations[0]; - var option = analyzerOptions.GetOption(CodeStyleOptions.UnusedParameters, parameter.Language, location.SourceTree, cancellationToken); + var option = analyzerOptions.GetOption(CodeStyleOptions2.UnusedParameters, parameter.Language, location.SourceTree, cancellationToken); if (option.Notification.Severity == ReportDiagnostic.Suppress || !ShouldReportUnusedParameters(parameter.ContainingSymbol, option.Value, option.Notification.Severity)) { diff --git a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs index b7cba5c0bf0fd..bd35b33c72c14 100644 --- a/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/RemoveUnusedParametersAndValues/AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs @@ -10,7 +10,6 @@ using Microsoft.CodeAnalysis.Operations; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; -using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.RemoveUnusedParametersAndValues { @@ -49,7 +48,7 @@ namespace Microsoft.CodeAnalysis.RemoveUnusedParametersAndValues /// Currently, we do not provide any code fix for removing unused parameters as it needs fixing the /// call sites and any automated fix can lead to subtle overload resolution differences, /// though this may change in future. - /// This diagnostic configuration is controlled by option. + /// This diagnostic configuration is controlled by option. /// internal abstract partial class AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer : AbstractBuiltInCodeStyleDiagnosticAnalyzer { @@ -86,14 +85,14 @@ internal abstract partial class AbstractRemoveUnusedParametersAndValuesDiagnosti private static readonly PropertiesMap s_propertiesMap = CreatePropertiesMap(); protected AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer( - Option> unusedValueExpressionStatementOption, - Option> unusedValueAssignmentOption, + Option2> unusedValueExpressionStatementOption, + Option2> unusedValueAssignmentOption, string language) : base(ImmutableDictionary.Empty .Add(s_expressionValueIsUnusedRule, unusedValueExpressionStatementOption) .Add(s_valueAssignedIsUnusedRule, unusedValueAssignmentOption), ImmutableDictionary.Empty - .Add(s_unusedParameterRule, CodeStyleOptions.UnusedParameters), + .Add(s_unusedParameterRule, CodeStyleOptions2.UnusedParameters), language) { UnusedValueExpressionStatementOption = unusedValueExpressionStatementOption; @@ -104,8 +103,8 @@ protected AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer( protected abstract bool SupportsDiscard(SyntaxTree tree); protected abstract bool MethodHasHandlesClause(IMethodSymbol method); protected abstract bool IsIfConditionalDirective(SyntaxNode node); - private Option> UnusedValueExpressionStatementOption { get; } - private Option> UnusedValueAssignmentOption { get; } + private Option2> UnusedValueExpressionStatementOption { get; } + private Option2> UnusedValueAssignmentOption { get; } /// /// Indicates if we should bail from removable assignment analysis for the given @@ -199,7 +198,7 @@ private bool TryGetOptions( { options = null; - var unusedParametersOption = analyzerOptions.GetOption(CodeStyleOptions.UnusedParameters, language, syntaxTree, cancellationToken); + var unusedParametersOption = analyzerOptions.GetOption(CodeStyleOptions2.UnusedParameters, language, syntaxTree, cancellationToken); var (unusedValueExpressionStatementPreference, unusedValueExpressionStatementSeverity) = GetPreferenceAndSeverity(UnusedValueExpressionStatementOption); var (unusedValueAssignmentPreference, unusedValueAssignmentSeverity) = GetPreferenceAndSeverity(UnusedValueAssignmentOption); if (unusedParametersOption.Notification.Severity == ReportDiagnostic.Suppress && @@ -216,7 +215,7 @@ private bool TryGetOptions( // Local functions. (UnusedValuePreference preference, ReportDiagnostic severity) GetPreferenceAndSeverity( - Option> codeStyleOption) + Option2> codeStyleOption) { var option = analyzerOptions.GetOption(codeStyleOption, syntaxTree, cancellationToken); var preferenceOpt = option?.Value; diff --git a/src/Features/Core/Portable/SimplifyInterpolation/AbstractSimplifyInterpolationDiagnosticAnalyzer.cs b/src/Features/Core/Portable/SimplifyInterpolation/AbstractSimplifyInterpolationDiagnosticAnalyzer.cs index 100abb5eab318..4ffafd53763ed 100644 --- a/src/Features/Core/Portable/SimplifyInterpolation/AbstractSimplifyInterpolationDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/SimplifyInterpolation/AbstractSimplifyInterpolationDiagnosticAnalyzer.cs @@ -19,7 +19,7 @@ internal abstract class AbstractSimplifyInterpolationDiagnosticAnalyzer< { protected AbstractSimplifyInterpolationDiagnosticAnalyzer() : base(IDEDiagnosticIds.SimplifyInterpolationId, - CodeStyleOptions.PreferSimplifiedInterpolation, + CodeStyleOptions2.PreferSimplifiedInterpolation, new LocalizableResourceString(nameof(FeaturesResources.Simplify_interpolation), FeaturesResources.ResourceManager, typeof(FeaturesResources)), new LocalizableResourceString(nameof(FeaturesResources.Interpolation_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -48,7 +48,7 @@ private void AnalyzeInterpolation(OperationAnalysisContext context) } var language = interpolation.Language; - var option = optionSet.GetOption(CodeStyleOptions.PreferSimplifiedInterpolation, language); + var option = optionSet.GetOption(CodeStyleOptions2.PreferSimplifiedInterpolation, language); if (!option.Value) { // No point in analyzing if the option is off. diff --git a/src/Features/Core/Portable/SimplifyThisOrMe/AbstractSimplifyThisOrMeDiagnosticAnalyzer.cs b/src/Features/Core/Portable/SimplifyThisOrMe/AbstractSimplifyThisOrMeDiagnosticAnalyzer.cs index 8d43317c23b74..5043b6fd3d147 100644 --- a/src/Features/Core/Portable/SimplifyThisOrMe/AbstractSimplifyThisOrMeDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/SimplifyThisOrMe/AbstractSimplifyThisOrMeDiagnosticAnalyzer.cs @@ -32,7 +32,7 @@ internal abstract class AbstractSimplifyThisOrMeDiagnosticAnalyzer< protected AbstractSimplifyThisOrMeDiagnosticAnalyzer() : base(IDEDiagnosticIds.RemoveQualificationDiagnosticId, - ImmutableHashSet.Create(CodeStyleOptions.QualifyFieldAccess, CodeStyleOptions.QualifyPropertyAccess, CodeStyleOptions.QualifyMethodAccess, CodeStyleOptions.QualifyEventAccess), + ImmutableHashSet.Create(CodeStyleOptions2.QualifyFieldAccess, CodeStyleOptions2.QualifyPropertyAccess, CodeStyleOptions2.QualifyMethodAccess, CodeStyleOptions2.QualifyEventAccess), new LocalizableResourceString(nameof(FeaturesResources.Remove_qualification), FeaturesResources.ResourceManager, typeof(FeaturesResources)), new LocalizableResourceString(nameof(WorkspacesResources.Name_can_be_simplified), WorkspacesResources.ResourceManager, typeof(WorkspacesResources))) { @@ -104,7 +104,7 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context) // used so we can provide a link in the preview to the options page. This value is // hard-coded there to be the one that will go to the code-style page. - builder["OptionName"] = nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration); + builder["OptionName"] = nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration); builder["OptionLanguage"] = model.Language; var diagnostic = DiagnosticHelper.Create( diff --git a/src/Features/Core/Portable/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs b/src/Features/Core/Portable/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs index ada0583d84a35..4593c2c4bae8a 100644 --- a/src/Features/Core/Portable/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs +++ b/src/Features/Core/Portable/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs @@ -83,9 +83,9 @@ protected SimplifyTypeNamesDiagnosticAnalyzerBase() public bool OpenFileOnly(OptionSet options) { var preferTypeKeywordInDeclarationOption = options.GetOption( - CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, GetLanguageName())!.Notification; + CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, GetLanguageName())!.Notification; var preferTypeKeywordInMemberAccessOption = options.GetOption( - CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, GetLanguageName())!.Notification; + CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, GetLanguageName())!.Notification; return !(preferTypeKeywordInDeclarationOption == NotificationOption.Warning || preferTypeKeywordInDeclarationOption == NotificationOption.Error || preferTypeKeywordInMemberAccessOption == NotificationOption.Warning || preferTypeKeywordInMemberAccessOption == NotificationOption.Error); @@ -143,7 +143,7 @@ public bool TrySimplify(SemanticModel model, SyntaxNode node, [NotNullWhen(true) internal static Diagnostic CreateDiagnostic(SemanticModel model, OptionSet optionSet, TextSpan issueSpan, string diagnosticId, bool inDeclaration) { - PerLanguageOption> option; + PerLanguageOption2> option; DiagnosticDescriptor descriptor; ReportDiagnostic severity; switch (diagnosticId) @@ -160,8 +160,8 @@ internal static Diagnostic CreateDiagnostic(SemanticModel model, OptionSet optio case IDEDiagnosticIds.PreferBuiltInOrFrameworkTypeDiagnosticId: option = inDeclaration - ? CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration - : CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess; + ? CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration + : CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess; descriptor = s_descriptorPreferBuiltinOrFrameworkType; var optionValue = optionSet.GetOption(option, model.Language)!; @@ -173,7 +173,7 @@ internal static Diagnostic CreateDiagnostic(SemanticModel model, OptionSet optio var tree = model.SyntaxTree; var builder = ImmutableDictionary.CreateBuilder(); - builder["OptionName"] = nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess); // TODO: need the actual one + builder["OptionName"] = nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess); // TODO: need the actual one builder["OptionLanguage"] = model.Language; var diagnostic = DiagnosticHelper.Create(descriptor, tree.GetLocation(issueSpan), severity, additionalLocations: null, builder.ToImmutable()); diff --git a/src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs b/src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs index f12f7bf5a55ca..b98e9437489f0 100644 --- a/src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs +++ b/src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs @@ -23,7 +23,7 @@ internal abstract class AbstractUseAutoPropertyAnalyzer< FeaturesResources.ResourceManager, typeof(FeaturesResources)); protected AbstractUseAutoPropertyAnalyzer() - : base(IDEDiagnosticIds.UseAutoPropertyDiagnosticId, CodeStyleOptions.PreferAutoProperties, s_title, s_title) + : base(IDEDiagnosticIds.UseAutoPropertyDiagnosticId, CodeStyleOptions2.PreferAutoProperties, s_title, s_title) { } @@ -51,7 +51,7 @@ private void AnalyzeSemanticModel(SemanticModelAnalysisContext context) var semanticModel = context.SemanticModel; // Don't even bother doing the analysis if the user doesn't even want auto-props. - var option = context.GetOption(CodeStyleOptions.PreferAutoProperties, semanticModel.Language); + var option = context.GetOption(CodeStyleOptions2.PreferAutoProperties, semanticModel.Language); if (!option.Value) { return; @@ -304,7 +304,7 @@ private void Process(AnalysisResult result, SemanticModelAnalysisContext context var additionalLocations = ImmutableArray.Create( propertyDeclaration.GetLocation(), variableDeclarator.GetLocation()); - var option = context.GetOption(CodeStyleOptions.PreferAutoProperties, propertyDeclaration.Language); + var option = context.GetOption(CodeStyleOptions2.PreferAutoProperties, propertyDeclaration.Language); if (option.Notification.Severity == ReportDiagnostic.Suppress) { // Avoid reporting diagnostics when the feature is disabled. This primarily avoids reporting the hidden diff --git a/src/Features/Core/Portable/UseCoalesceExpression/AbstractUseCoalesceExpressionDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseCoalesceExpression/AbstractUseCoalesceExpressionDiagnosticAnalyzer.cs index 911672e5c569d..f1ffff9b961ae 100644 --- a/src/Features/Core/Portable/UseCoalesceExpression/AbstractUseCoalesceExpressionDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseCoalesceExpression/AbstractUseCoalesceExpressionDiagnosticAnalyzer.cs @@ -26,7 +26,7 @@ internal abstract class AbstractUseCoalesceExpressionDiagnosticAnalyzer< { protected AbstractUseCoalesceExpressionDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseCoalesceExpressionDiagnosticId, - CodeStyleOptions.PreferCoalesceExpression, + CodeStyleOptions2.PreferCoalesceExpression, new LocalizableResourceString(nameof(FeaturesResources.Use_coalesce_expression), FeaturesResources.ResourceManager, typeof(FeaturesResources)), new LocalizableResourceString(nameof(FeaturesResources.Null_check_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -48,7 +48,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context) { var conditionalExpression = (TConditionalExpressionSyntax)context.Node; - var option = context.GetOption(CodeStyleOptions.PreferCoalesceExpression, conditionalExpression.Language); + var option = context.GetOption(CodeStyleOptions2.PreferCoalesceExpression, conditionalExpression.Language); if (!option.Value) { return; diff --git a/src/Features/Core/Portable/UseCoalesceExpression/AbstractUseCoalesceExpressionForNullableDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseCoalesceExpression/AbstractUseCoalesceExpressionForNullableDiagnosticAnalyzer.cs index 6644ece7ee18f..444ee37fdbe62 100644 --- a/src/Features/Core/Portable/UseCoalesceExpression/AbstractUseCoalesceExpressionForNullableDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseCoalesceExpression/AbstractUseCoalesceExpressionForNullableDiagnosticAnalyzer.cs @@ -28,7 +28,7 @@ internal abstract class AbstractUseCoalesceExpressionForNullableDiagnosticAnalyz { protected AbstractUseCoalesceExpressionForNullableDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseCoalesceExpressionForNullableDiagnosticId, - CodeStyleOptions.PreferCoalesceExpression, + CodeStyleOptions2.PreferCoalesceExpression, new LocalizableResourceString(nameof(FeaturesResources.Use_coalesce_expression), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { } @@ -51,7 +51,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context) var cancellationToken = context.CancellationToken; - var option = context.GetOption(CodeStyleOptions.PreferCoalesceExpression, conditionalExpression.Language); + var option = context.GetOption(CodeStyleOptions2.PreferCoalesceExpression, conditionalExpression.Language); if (!option.Value) { return; diff --git a/src/Features/Core/Portable/UseCollectionInitializer/AbstractUseCollectionInitializerDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseCollectionInitializer/AbstractUseCollectionInitializerDiagnosticAnalyzer.cs index 817ae88cddc3c..7428f1e65ca90 100644 --- a/src/Features/Core/Portable/UseCollectionInitializer/AbstractUseCollectionInitializerDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseCollectionInitializer/AbstractUseCollectionInitializerDiagnosticAnalyzer.cs @@ -38,7 +38,7 @@ public override DiagnosticAnalyzerCategory GetAnalyzerCategory() protected AbstractUseCollectionInitializerDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseCollectionInitializerDiagnosticId, - CodeStyleOptions.PreferCollectionInitializer, + CodeStyleOptions2.PreferCollectionInitializer, new LocalizableResourceString(nameof(FeaturesResources.Simplify_collection_initialization), FeaturesResources.ResourceManager, typeof(FeaturesResources)), new LocalizableResourceString(nameof(FeaturesResources.Collection_initialization_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -73,7 +73,7 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context, INamedTypeSymbol ien var language = objectCreationExpression.Language; var cancellationToken = context.CancellationToken; - var option = context.GetOption(CodeStyleOptions.PreferCollectionInitializer, language); + var option = context.GetOption(CodeStyleOptions2.PreferCollectionInitializer, language); if (!option.Value) { // not point in analyzing if the option is off. @@ -130,7 +130,7 @@ private void FadeOutCode( var syntaxTree = context.Node.SyntaxTree; var fadeOutCode = context.GetOption( - CodeStyleOptions.PreferCollectionInitializer_FadeOutCode, context.Node.Language); + CodeStyleOptions2.PreferCollectionInitializer_FadeOutCode, context.Node.Language); if (!fadeOutCode) { return; diff --git a/src/Features/Core/Portable/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs index 965c7e8088027..5a41f29ea3240 100644 --- a/src/Features/Core/Portable/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseCompoundAssignment/AbstractUseCompoundAssignmentDiagnosticAnalyzer.cs @@ -39,7 +39,7 @@ protected AbstractUseCompoundAssignmentDiagnosticAnalyzer( ISyntaxFacts syntaxFacts, ImmutableArray<(TSyntaxKind exprKind, TSyntaxKind assignmentKind, TSyntaxKind tokenKind)> kinds) : base(IDEDiagnosticIds.UseCompoundAssignmentDiagnosticId, - CodeStyleOptions.PreferCompoundAssignment, + CodeStyleOptions2.PreferCompoundAssignment, new LocalizableResourceString( nameof(FeaturesResources.Use_compound_assignment), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -61,7 +61,7 @@ private void AnalyzeAssignment(SyntaxNodeAnalysisContext context) var assignment = (TAssignmentSyntax)context.Node; var syntaxTree = assignment.SyntaxTree; - var option = context.GetOption(CodeStyleOptions.PreferCompoundAssignment, assignment.Language); + var option = context.GetOption(CodeStyleOptions2.PreferCompoundAssignment, assignment.Language); if (!option.Value) { // Bail immediately if the user has disabled this feature. diff --git a/src/Features/Core/Portable/UseConditionalExpression/AbstractUseConditionalExpressionDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseConditionalExpression/AbstractUseConditionalExpressionDiagnosticAnalyzer.cs index a5cbe3c5ea596..714a5e1714760 100644 --- a/src/Features/Core/Portable/UseConditionalExpression/AbstractUseConditionalExpressionDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseConditionalExpression/AbstractUseConditionalExpressionDiagnosticAnalyzer.cs @@ -18,7 +18,7 @@ internal abstract class AbstractUseConditionalExpressionDiagnosticAnalyzer< : AbstractBuiltInCodeStyleDiagnosticAnalyzer where TIfStatementSyntax : SyntaxNode { - private readonly PerLanguageOption> _option; + private readonly PerLanguageOption2> _option; public sealed override DiagnosticAnalyzerCategory GetAnalyzerCategory() => DiagnosticAnalyzerCategory.SemanticSpanAnalysis; @@ -26,7 +26,7 @@ public sealed override DiagnosticAnalyzerCategory GetAnalyzerCategory() protected AbstractUseConditionalExpressionDiagnosticAnalyzer( string descriptorId, LocalizableResourceString message, - PerLanguageOption> option) + PerLanguageOption2> option) : base(descriptorId, option, new LocalizableResourceString(nameof(FeaturesResources.Convert_to_conditional_expression), FeaturesResources.ResourceManager, typeof(FeaturesResources)), diff --git a/src/Features/Core/Portable/UseConditionalExpression/ForAssignment/AbstractUseConditionalExpressionForAssignmentDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseConditionalExpression/ForAssignment/AbstractUseConditionalExpressionForAssignmentDiagnosticAnalyzer.cs index 5aae8f065f93e..eaaa04aa5d787 100644 --- a/src/Features/Core/Portable/UseConditionalExpression/ForAssignment/AbstractUseConditionalExpressionForAssignmentDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseConditionalExpression/ForAssignment/AbstractUseConditionalExpressionForAssignmentDiagnosticAnalyzer.cs @@ -17,7 +17,7 @@ protected AbstractUseConditionalExpressionForAssignmentDiagnosticAnalyzer( LocalizableResourceString message) : base(IDEDiagnosticIds.UseConditionalExpressionForAssignmentDiagnosticId, message, - CodeStyleOptions.PreferConditionalExpressionOverAssignment) + CodeStyleOptions2.PreferConditionalExpressionOverAssignment) { } diff --git a/src/Features/Core/Portable/UseConditionalExpression/ForReturn/AbstractUseConditionalExpressionForReturnDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseConditionalExpression/ForReturn/AbstractUseConditionalExpressionForReturnDiagnosticAnalyzer.cs index 53f4e6168a8f6..bc7ccd7531b74 100644 --- a/src/Features/Core/Portable/UseConditionalExpression/ForReturn/AbstractUseConditionalExpressionForReturnDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseConditionalExpression/ForReturn/AbstractUseConditionalExpressionForReturnDiagnosticAnalyzer.cs @@ -17,7 +17,7 @@ protected AbstractUseConditionalExpressionForReturnDiagnosticAnalyzer( LocalizableResourceString message) : base(IDEDiagnosticIds.UseConditionalExpressionForReturnDiagnosticId, message, - CodeStyleOptions.PreferConditionalExpressionOverReturn) + CodeStyleOptions2.PreferConditionalExpressionOverReturn) { } diff --git a/src/Features/Core/Portable/UseExplicitTupleName/UseExplicitTupleNameDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseExplicitTupleName/UseExplicitTupleNameDiagnosticAnalyzer.cs index da75153c5fc68..11c97f306188d 100644 --- a/src/Features/Core/Portable/UseExplicitTupleName/UseExplicitTupleNameDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseExplicitTupleName/UseExplicitTupleNameDiagnosticAnalyzer.cs @@ -18,7 +18,7 @@ internal class UseExplicitTupleNameDiagnosticAnalyzer : AbstractBuiltInCodeStyle public UseExplicitTupleNameDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseExplicitTupleNameDiagnosticId, - CodeStyleOptions.PreferExplicitTupleNames, + CodeStyleOptions2.PreferExplicitTupleNames, title: new LocalizableResourceString(nameof(FeaturesResources.Use_explicitly_provided_tuple_name), FeaturesResources.ResourceManager, typeof(FeaturesResources)), messageFormat: new LocalizableResourceString(nameof(FeaturesResources.Prefer_explicitly_provided_tuple_element_name), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -32,7 +32,7 @@ protected override void InitializeWorker(AnalysisContext context) private void AnalyzeOperation(OperationAnalysisContext context) { // We only create a diagnostic if the option's value is set to true. - var option = context.GetOption(CodeStyleOptions.PreferExplicitTupleNames, context.Compilation.Language); + var option = context.GetOption(CodeStyleOptions2.PreferExplicitTupleNames, context.Compilation.Language); if (!option.Value) { return; diff --git a/src/Features/Core/Portable/UseInferredMemberName/AbstractUseInferredMemberNameDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseInferredMemberName/AbstractUseInferredMemberNameDiagnosticAnalyzer.cs index c118d7018d4b2..992c466304e05 100644 --- a/src/Features/Core/Portable/UseInferredMemberName/AbstractUseInferredMemberNameDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseInferredMemberName/AbstractUseInferredMemberNameDiagnosticAnalyzer.cs @@ -16,7 +16,7 @@ internal abstract class AbstractUseInferredMemberNameDiagnosticAnalyzer : Abstra public AbstractUseInferredMemberNameDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseInferredMemberNameDiagnosticId, - options: ImmutableHashSet.Create(CodeStyleOptions.PreferInferredAnonymousTypeMemberNames, CodeStyleOptions.PreferInferredTupleNames), + options: ImmutableHashSet.Create(CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames, CodeStyleOptions2.PreferInferredTupleNames), new LocalizableResourceString(nameof(FeaturesResources.Use_inferred_member_name), FeaturesResources.ResourceManager, typeof(FeaturesResources)), new LocalizableResourceString(nameof(FeaturesResources.Member_name_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { diff --git a/src/Features/Core/Portable/UseIsNullCheck/AbstractUseIsNullForReferenceEqualsDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseIsNullCheck/AbstractUseIsNullForReferenceEqualsDiagnosticAnalyzer.cs index 92f964c28861b..cf776e07848d7 100644 --- a/src/Features/Core/Portable/UseIsNullCheck/AbstractUseIsNullForReferenceEqualsDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseIsNullCheck/AbstractUseIsNullForReferenceEqualsDiagnosticAnalyzer.cs @@ -20,7 +20,7 @@ internal abstract class AbstractUseIsNullCheckForReferenceEqualsDiagnosticAnalyz { protected AbstractUseIsNullCheckForReferenceEqualsDiagnosticAnalyzer(LocalizableString title) : base(IDEDiagnosticIds.UseIsNullCheckDiagnosticId, - CodeStyleOptions.PreferIsNullCheckOverReferenceEqualityMethod, + CodeStyleOptions2.PreferIsNullCheckOverReferenceEqualityMethod, title, new LocalizableResourceString(nameof(FeaturesResources.Null_check_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -63,7 +63,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context, IMethodSymbol refe return; } - var option = context.GetOption(CodeStyleOptions.PreferIsNullCheckOverReferenceEqualityMethod, semanticModel.Language); + var option = context.GetOption(CodeStyleOptions2.PreferIsNullCheckOverReferenceEqualityMethod, semanticModel.Language); if (!option.Value) { return; diff --git a/src/Features/Core/Portable/UseNullPropagation/AbstractUseNullPropagationDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseNullPropagation/AbstractUseNullPropagationDiagnosticAnalyzer.cs index 6ab4cf2e3c11b..d9615b84d8def 100644 --- a/src/Features/Core/Portable/UseNullPropagation/AbstractUseNullPropagationDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseNullPropagation/AbstractUseNullPropagationDiagnosticAnalyzer.cs @@ -38,7 +38,7 @@ internal abstract class AbstractUseNullPropagationDiagnosticAnalyzer< { protected AbstractUseNullPropagationDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseNullPropagationDiagnosticId, - CodeStyleOptions.PreferNullPropagation, + CodeStyleOptions2.PreferNullPropagation, new LocalizableResourceString(nameof(FeaturesResources.Use_null_propagation), FeaturesResources.ResourceManager, typeof(FeaturesResources)), new LocalizableResourceString(nameof(FeaturesResources.Null_check_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -87,7 +87,7 @@ private void AnalyzeSyntax( return; } - var option = context.GetOption(CodeStyleOptions.PreferNullPropagation, conditionalExpression.Language); + var option = context.GetOption(CodeStyleOptions2.PreferNullPropagation, conditionalExpression.Language); if (!option.Value) { return; diff --git a/src/Features/Core/Portable/UseObjectInitializer/AbstractUseObjectInitializerDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseObjectInitializer/AbstractUseObjectInitializerDiagnosticAnalyzer.cs index ddd1b624e0cf1..9ec281a9bd185 100644 --- a/src/Features/Core/Portable/UseObjectInitializer/AbstractUseObjectInitializerDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseObjectInitializer/AbstractUseObjectInitializerDiagnosticAnalyzer.cs @@ -6,7 +6,6 @@ using System.Collections.Immutable; using System.Linq; -using System.Threading; using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.LanguageServices; @@ -36,7 +35,7 @@ internal abstract partial class AbstractUseObjectInitializerDiagnosticAnalyzer< protected AbstractUseObjectInitializerDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseObjectInitializerDiagnosticId, - CodeStyleOptions.PreferObjectInitializer, + CodeStyleOptions2.PreferObjectInitializer, new LocalizableResourceString(nameof(FeaturesResources.Simplify_object_initialization), FeaturesResources.ResourceManager, typeof(FeaturesResources)), new LocalizableResourceString(nameof(FeaturesResources.Object_initialization_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -60,7 +59,7 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context) var objectCreationExpression = (TObjectCreationExpressionSyntax)context.Node; var language = objectCreationExpression.Language; - var option = context.GetOption(CodeStyleOptions.PreferObjectInitializer, language); + var option = context.GetOption(CodeStyleOptions2.PreferObjectInitializer, language); if (!option.Value) { // not point in analyzing if the option is off. @@ -109,7 +108,7 @@ private void FadeOutCode( var syntaxTree = context.Node.SyntaxTree; var fadeOutCode = context.GetOption( - CodeStyleOptions.PreferObjectInitializer_FadeOutCode, context.Node.Language); + CodeStyleOptions2.PreferObjectInitializer_FadeOutCode, context.Node.Language); if (!fadeOutCode) { return; diff --git a/src/Features/Core/Portable/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs index 9d5244b6ce056..db7ca87bde76b 100644 --- a/src/Features/Core/Portable/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseSystemHashCode/UseSystemHashCodeDiagnosticAnalyzer.cs @@ -15,7 +15,7 @@ internal class UseSystemHashCodeDiagnosticAnalyzer : AbstractBuiltInCodeStyleDia { public UseSystemHashCodeDiagnosticAnalyzer() : base(IDEDiagnosticIds.UseSystemHashCode, - CodeStyleOptions.PreferSystemHashCode, + CodeStyleOptions2.PreferSystemHashCode, new LocalizableResourceString(nameof(FeaturesResources.Use_System_HashCode), FeaturesResources.ResourceManager, typeof(FeaturesResources)), new LocalizableResourceString(nameof(FeaturesResources.GetHashCode_implementation_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources))) { @@ -54,7 +54,7 @@ private void AnalyzeOperationBlock(Analyzer analyzer, OperationBlockAnalysisCont var syntaxTree = operation.Syntax.SyntaxTree; var cancellationToken = context.CancellationToken; - var option = context.Options.GetOption(CodeStyleOptions.PreferSystemHashCode, operation.Language, syntaxTree, cancellationToken); + var option = context.Options.GetOption(CodeStyleOptions2.PreferSystemHashCode, operation.Language, syntaxTree, cancellationToken); if (option?.Value != true) { return; diff --git a/src/Features/Core/Portable/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs b/src/Features/Core/Portable/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs index 971911a152981..34e4e1f3c52c6 100644 --- a/src/Features/Core/Portable/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs +++ b/src/Features/Core/Portable/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs @@ -35,9 +35,9 @@ namespace Microsoft.CodeAnalysis.UseThrowExpression internal abstract class AbstractUseThrowExpressionDiagnosticAnalyzer : AbstractBuiltInCodeStyleDiagnosticAnalyzer { - private readonly Option> _preferThrowExpressionOption; + private readonly Option2> _preferThrowExpressionOption; - protected AbstractUseThrowExpressionDiagnosticAnalyzer(Option> preferThrowExpressionOption, string language) + protected AbstractUseThrowExpressionDiagnosticAnalyzer(Option2> preferThrowExpressionOption, string language) : base(IDEDiagnosticIds.UseThrowExpressionDiagnosticId, preferThrowExpressionOption, language, diff --git a/src/Features/Core/Portable/Wrapping/BinaryExpression/BinaryExpressionCodeActionComputer.cs b/src/Features/Core/Portable/Wrapping/BinaryExpression/BinaryExpressionCodeActionComputer.cs index 69e2910d6dd7f..dc2d66d2bc485 100644 --- a/src/Features/Core/Portable/Wrapping/BinaryExpression/BinaryExpressionCodeActionComputer.cs +++ b/src/Features/Core/Portable/Wrapping/BinaryExpression/BinaryExpressionCodeActionComputer.cs @@ -53,7 +53,7 @@ public BinaryExpressionCodeActionComputer( : base(service, document, originalSourceText, options, cancellationToken) { _exprsAndOperators = exprsAndOperators; - _preference = options.GetOption(CodeStyleOptions.OperatorPlacementWhenWrapping); + _preference = options.GetOption(CodeStyleOptions2.OperatorPlacementWhenWrapping); var generator = SyntaxGenerator.GetGenerator(document); diff --git a/src/Features/VisualBasic/Portable/AddAccessibilityModifiers/VisualBasicAddAccessibilityModifiersDiagnosticAnalyzer.vb b/src/Features/VisualBasic/Portable/AddAccessibilityModifiers/VisualBasicAddAccessibilityModifiersDiagnosticAnalyzer.vb index 66c7d62f7068a..2edd455cacfc0 100644 --- a/src/Features/VisualBasic/Portable/AddAccessibilityModifiers/VisualBasicAddAccessibilityModifiersDiagnosticAnalyzer.vb +++ b/src/Features/VisualBasic/Portable/AddAccessibilityModifiers/VisualBasicAddAccessibilityModifiersDiagnosticAnalyzer.vb @@ -16,20 +16,20 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.AddAccessibilityModifiers Protected Overrides Sub ProcessCompilationUnit( context As SyntaxTreeAnalysisContext, generator As SyntaxGenerator, - [option] As CodeStyleOption(Of AccessibilityModifiersRequired), compilationUnit As CompilationUnitSyntax) + [option] As CodeStyleOption2(Of AccessibilityModifiersRequired), compilationUnit As CompilationUnitSyntax) ProcessMembers(context, generator, [option], compilationUnit.Members) End Sub Private Sub ProcessMembers(context As SyntaxTreeAnalysisContext, generator As SyntaxGenerator, - [option] As CodeStyleOption(Of AccessibilityModifiersRequired), members As SyntaxList(Of StatementSyntax)) + [option] As CodeStyleOption2(Of AccessibilityModifiersRequired), members As SyntaxList(Of StatementSyntax)) For Each member In members ProcessMember(context, generator, [option], member) Next End Sub Private Sub ProcessMember(context As SyntaxTreeAnalysisContext, generator As SyntaxGenerator, - [option] As CodeStyleOption(Of AccessibilityModifiersRequired), member As StatementSyntax) + [option] As CodeStyleOption2(Of AccessibilityModifiersRequired), member As StatementSyntax) If member.Kind() = SyntaxKind.NamespaceBlock Then diff --git a/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicSimplifyTypeNamesDiagnosticAnalyzer.vb b/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicSimplifyTypeNamesDiagnosticAnalyzer.vb index 888f827632022..a94e150552a41 100644 --- a/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicSimplifyTypeNamesDiagnosticAnalyzer.vb +++ b/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicSimplifyTypeNamesDiagnosticAnalyzer.vb @@ -104,10 +104,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.SimplifyTypeNames End If ' set proper diagnostic ids. - If replacementSyntax.HasAnnotations(NameOf(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration)) Then + If replacementSyntax.HasAnnotations(NameOf(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration)) Then inDeclaration = True diagnosticId = IDEDiagnosticIds.PreferBuiltInOrFrameworkTypeDiagnosticId - ElseIf replacementSyntax.HasAnnotations(NameOf(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess)) Then + ElseIf replacementSyntax.HasAnnotations(NameOf(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess)) Then inDeclaration = False diagnosticId = IDEDiagnosticIds.PreferBuiltInOrFrameworkTypeDiagnosticId ElseIf expression.Kind = SyntaxKind.SimpleMemberAccessExpression Then diff --git a/src/Features/VisualBasic/Portable/UseInferredMemberName/VisualBasicUseInferredMemberNameDiagnosticAnalyzer.vb b/src/Features/VisualBasic/Portable/UseInferredMemberName/VisualBasicUseInferredMemberNameDiagnosticAnalyzer.vb index 2ac6131c0f0b7..11e916de11d51 100644 --- a/src/Features/VisualBasic/Portable/UseInferredMemberName/VisualBasicUseInferredMemberNameDiagnosticAnalyzer.vb +++ b/src/Features/VisualBasic/Portable/UseInferredMemberName/VisualBasicUseInferredMemberNameDiagnosticAnalyzer.vb @@ -51,7 +51,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UseInferredMemberName Dim argument = DirectCast(nameColonEquals.Parent, SimpleArgumentSyntax) Dim preference = options.GetOption( - CodeStyleOptions.PreferInferredTupleNames, context.Compilation.Language, syntaxTree, cancellationToken) + CodeStyleOptions2.PreferInferredTupleNames, context.Compilation.Language, syntaxTree, cancellationToken) If Not preference.Value OrElse Not VisualBasicInferredMemberNameReducer.CanSimplifyTupleName(argument, parseOptions) Then Return @@ -85,7 +85,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UseInferredMemberName End If Dim preference = options.GetOption( - CodeStyleOptions.PreferInferredAnonymousTypeMemberNames, context.Compilation.Language, syntaxTree, cancellationToken) + CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames, context.Compilation.Language, syntaxTree, cancellationToken) If Not preference.Value OrElse Not VisualBasicInferredMemberNameReducer.CanSimplifyNamedFieldInitializer(fieldInitializer) Then