From 6e1e5dd3f5789d5e197a53632b543dfb3951d1b6 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Tue, 10 Mar 2020 12:27:09 -0700 Subject: [PATCH] Move VS layer and some of the options it depends on to the new internal API --- .../SplitStringLiteralOptions.cs | 4 +- .../Core/Options/ColorSchemeOptions.cs | 4 +- .../Shared/Options/FeatureOnOffOptions.cs | 6 +- .../CSharp/Impl/Options/AutomationObject.cs | 280 +++++++++--------- .../Impl/Options/Formatting/CodeStylePage.cs | 4 +- .../FormattingOptionPageControl.xaml.cs | 2 +- .../Impl/Options/Formatting/StyleViewModel.cs | 48 +-- .../PreviewPane/PreviewPaneService.cs | 2 +- .../VisualStudioNavigationOptions.cs | 2 +- .../Impl/Options/AbstractOptionPageControl.cs | 14 +- .../Options/AbstractOptionPreviewViewModel.cs | 4 +- .../Options/GridOptionPreviewControl.xaml.cs | 4 +- .../Core/Impl/Options/OptionBinding.cs | 4 +- .../Core/Impl/Options/OptionStore.cs | 16 + .../Impl/Options/PerLanguageOptionBinding.cs | 4 +- .../Style/EnumCodeStyleOptionViewModel.cs | 4 +- .../Impl/Options/AutomationObject.vb | 70 ++--- .../Impl/Options/Formatting/CodeStylePage.vb | 2 +- .../Impl/Options/StyleViewModel.vb | 48 +-- ...torConfigDocumentOptionsProviderFactory.cs | 4 +- .../SolutionCrawler/SolutionCrawlerOptions.cs | 2 +- .../CodeFixes/DocumentBasedFixAllProvider.cs | 1 + 22 files changed, 273 insertions(+), 256 deletions(-) diff --git a/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralOptions.cs b/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralOptions.cs index 7424402229f5a..bba9b007401b3 100644 --- a/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralOptions.cs +++ b/src/EditorFeatures/CSharp/SplitStringLiteral/SplitStringLiteralOptions.cs @@ -13,8 +13,8 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.SplitStringLiteral { internal class SplitStringLiteralOptions { - public static PerLanguageOption Enabled = - new PerLanguageOption(nameof(SplitStringLiteralOptions), nameof(Enabled), defaultValue: true, + public static PerLanguageOption2 Enabled = + new PerLanguageOption2(nameof(SplitStringLiteralOptions), nameof(Enabled), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.SplitStringLiterals")); } diff --git a/src/EditorFeatures/Core/Options/ColorSchemeOptions.cs b/src/EditorFeatures/Core/Options/ColorSchemeOptions.cs index d61f096a33ba5..eb145d305fc79 100644 --- a/src/EditorFeatures/Core/Options/ColorSchemeOptions.cs +++ b/src/EditorFeatures/Core/Options/ColorSchemeOptions.cs @@ -12,12 +12,12 @@ internal static class ColorSchemeOptions { internal const string ColorSchemeSettingKey = "TextEditor.Roslyn.ColorScheme"; - public static readonly Option ColorScheme = new Option(nameof(ColorSchemeOptions), + public static readonly Option2 ColorScheme = new Option2(nameof(ColorSchemeOptions), nameof(ColorScheme), defaultValue: SchemeName.VisualStudio2019, storageLocations: new RoamingProfileStorageLocation(ColorSchemeSettingKey)); - public static readonly Option LegacyUseEnhancedColors = new Option(nameof(ColorSchemeOptions), + public static readonly Option2 LegacyUseEnhancedColors = new Option2(nameof(ColorSchemeOptions), nameof(LegacyUseEnhancedColors), defaultValue: UseEnhancedColors.Default, storageLocations: new RoamingProfileStorageLocation("WindowManagement.Options.UseEnhancedColorsForManagedLanguages")); diff --git a/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs b/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs index 8315a1da9b78b..d7e2354361720 100644 --- a/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs +++ b/src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs @@ -79,16 +79,16 @@ internal static class FeatureOnOffOptions public static readonly PerLanguageOption2 StreamingGoToImplementation = new PerLanguageOption2( nameof(FeatureOnOffOptions), nameof(StreamingGoToImplementation), defaultValue: true); - public static readonly Option NavigateToDecompiledSources = new Option( + public static readonly Option2 NavigateToDecompiledSources = new Option2( nameof(FeatureOnOffOptions), nameof(NavigateToDecompiledSources), defaultValue: false, storageLocations: new RoamingProfileStorageLocation($"TextEditor.{nameof(NavigateToDecompiledSources)}")); - public static readonly Option UseEnhancedColors = new Option( + public static readonly Option2 UseEnhancedColors = new Option2( nameof(FeatureOnOffOptions), nameof(UseEnhancedColors), defaultValue: 1, storageLocations: new RoamingProfileStorageLocation("WindowManagement.Options.UseEnhancedColorsForManagedLanguages")); // Note: no storage location since this is intentionally a session variable - public static readonly Option AcceptedDecompilerDisclaimer = new Option( + public static readonly Option2 AcceptedDecompilerDisclaimer = new Option2( nameof(FeatureOnOffOptions), nameof(AcceptedDecompilerDisclaimer), defaultValue: false); } diff --git a/src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs b/src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs index ade571f23ba55..67651a2866bb1 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs +++ b/src/VisualStudio/CSharp/Impl/Options/AutomationObject.cs @@ -151,46 +151,46 @@ public int HighlightReferences public int Indent_BlockContents { - get { return GetBooleanOption(CSharpFormattingOptions.IndentBlock); } - set { SetBooleanOption(CSharpFormattingOptions.IndentBlock, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.IndentBlock); } + set { SetBooleanOption(CSharpFormattingOptions2.IndentBlock, value); } } public int Indent_Braces { - get { return GetBooleanOption(CSharpFormattingOptions.IndentBraces); } - set { SetBooleanOption(CSharpFormattingOptions.IndentBraces, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.IndentBraces); } + set { SetBooleanOption(CSharpFormattingOptions2.IndentBraces, value); } } public int Indent_CaseContents { - get { return GetBooleanOption(CSharpFormattingOptions.IndentSwitchCaseSection); } - set { SetBooleanOption(CSharpFormattingOptions.IndentSwitchCaseSection, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.IndentSwitchCaseSection); } + set { SetBooleanOption(CSharpFormattingOptions2.IndentSwitchCaseSection, value); } } public int Indent_CaseContentsWhenBlock { - get { return GetBooleanOption(CSharpFormattingOptions.IndentSwitchCaseSectionWhenBlock); } - set { SetBooleanOption(CSharpFormattingOptions.IndentSwitchCaseSectionWhenBlock, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.IndentSwitchCaseSectionWhenBlock); } + set { SetBooleanOption(CSharpFormattingOptions2.IndentSwitchCaseSectionWhenBlock, value); } } public int Indent_CaseLabels { - get { return GetBooleanOption(CSharpFormattingOptions.IndentSwitchSection); } - set { SetBooleanOption(CSharpFormattingOptions.IndentSwitchSection, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.IndentSwitchSection); } + set { SetBooleanOption(CSharpFormattingOptions2.IndentSwitchSection, value); } } public int Indent_FlushLabelsLeft { get { - var option = _workspace.Options.GetOption(CSharpFormattingOptions.LabelPositioning); + var option = _workspace.Options.GetOption(CSharpFormattingOptions2.LabelPositioning); return option == LabelPositionOptions.LeftMost ? 1 : 0; } set { _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options - .WithChangedOption(CSharpFormattingOptions.LabelPositioning, value == 1 ? LabelPositionOptions.LeftMost : LabelPositionOptions.NoIndent))); + .WithChangedOption(CSharpFormattingOptions2.LabelPositioning, value == 1 ? LabelPositionOptions.LeftMost : LabelPositionOptions.NoIndent))); } } @@ -198,13 +198,13 @@ public int Indent_UnindentLabels { get { - return (int)_workspace.Options.GetOption(CSharpFormattingOptions.LabelPositioning); + return (int)_workspace.Options.GetOption(CSharpFormattingOptions2.LabelPositioning); } set { _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options - .WithChangedOption(CSharpFormattingOptions.LabelPositioning, value))); + .WithChangedOption(CSharpFormattingOptions2.LabelPositioning, value))); } } @@ -228,92 +228,92 @@ public int SnippetsBehavior public int NewLines_AnonymousTypeInitializer_EachMember { - get { return GetBooleanOption(CSharpFormattingOptions.NewLineForMembersInAnonymousTypes); } - set { SetBooleanOption(CSharpFormattingOptions.NewLineForMembersInAnonymousTypes, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLineForMembersInAnonymousTypes); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLineForMembersInAnonymousTypes, value); } } public int NewLines_Braces_AnonymousMethod { - get { return GetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInAnonymousMethods); } - set { SetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInAnonymousMethods, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInAnonymousMethods); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInAnonymousMethods, value); } } public int NewLines_Braces_AnonymousTypeInitializer { - get { return GetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInAnonymousTypes); } - set { SetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInAnonymousTypes, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInAnonymousTypes); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInAnonymousTypes, value); } } public int NewLines_Braces_ControlFlow { - get { return GetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInControlBlocks); } - set { SetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInControlBlocks, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInControlBlocks); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInControlBlocks, value); } } public int NewLines_Braces_LambdaExpressionBody { - get { return GetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInLambdaExpressionBody); } - set { SetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInLambdaExpressionBody, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInLambdaExpressionBody); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInLambdaExpressionBody, value); } } public int NewLines_Braces_Method { - get { return GetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInMethods); } - set { SetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInMethods, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInMethods); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInMethods, value); } } public int NewLines_Braces_Property { - get { return GetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInProperties); } - set { SetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInProperties, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInProperties); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInProperties, value); } } public int NewLines_Braces_Accessor { - get { return GetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInAccessors); } - set { SetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInAccessors, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInAccessors); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInAccessors, value); } } public int NewLines_Braces_ObjectInitializer { - get { return GetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers); } - set { SetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInObjectCollectionArrayInitializers); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInObjectCollectionArrayInitializers, value); } } public int NewLines_Braces_Type { - get { return GetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInTypes); } - set { SetBooleanOption(CSharpFormattingOptions.NewLinesForBracesInTypes, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInTypes); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLinesForBracesInTypes, value); } } public int NewLines_Keywords_Catch { - get { return GetBooleanOption(CSharpFormattingOptions.NewLineForCatch); } - set { SetBooleanOption(CSharpFormattingOptions.NewLineForCatch, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLineForCatch); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLineForCatch, value); } } public int NewLines_Keywords_Else { - get { return GetBooleanOption(CSharpFormattingOptions.NewLineForElse); } - set { SetBooleanOption(CSharpFormattingOptions.NewLineForElse, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLineForElse); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLineForElse, value); } } public int NewLines_Keywords_Finally { - get { return GetBooleanOption(CSharpFormattingOptions.NewLineForFinally); } - set { SetBooleanOption(CSharpFormattingOptions.NewLineForFinally, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLineForFinally); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLineForFinally, value); } } public int NewLines_ObjectInitializer_EachMember { - get { return GetBooleanOption(CSharpFormattingOptions.NewLineForMembersInObjectInit); } - set { SetBooleanOption(CSharpFormattingOptions.NewLineForMembersInObjectInit, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLineForMembersInObjectInit); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLineForMembersInObjectInit, value); } } public int NewLines_QueryExpression_EachClause { - get { return GetBooleanOption(CSharpFormattingOptions.NewLineForClausesInQuery); } - set { SetBooleanOption(CSharpFormattingOptions.NewLineForClausesInQuery, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.NewLineForClausesInQuery); } + set { SetBooleanOption(CSharpFormattingOptions2.NewLineForClausesInQuery, value); } } public int Refactoring_Verification_Enabled @@ -382,51 +382,51 @@ public int AddImport_SuggestForTypesInNuGetPackages public int Space_AfterBasesColon { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceAfterColonInBaseTypeDeclaration); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceAfterColonInBaseTypeDeclaration, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceAfterColonInBaseTypeDeclaration); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceAfterColonInBaseTypeDeclaration, value); } } public int Space_AfterCast { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceAfterCast); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceAfterCast, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceAfterCast); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceAfterCast, value); } } public int Space_AfterComma { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceAfterComma); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceAfterComma, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceAfterComma); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceAfterComma, value); } } public int Space_AfterDot { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceAfterDot); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceAfterDot, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceAfterDot); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceAfterDot, value); } } public int Space_AfterMethodCallName { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceAfterMethodCallName); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceAfterMethodCallName, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceAfterMethodCallName); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceAfterMethodCallName, value); } } public int Space_AfterMethodDeclarationName { - get { return GetBooleanOption(CSharpFormattingOptions.SpacingAfterMethodDeclarationName); } - set { SetBooleanOption(CSharpFormattingOptions.SpacingAfterMethodDeclarationName, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpacingAfterMethodDeclarationName); } + set { SetBooleanOption(CSharpFormattingOptions2.SpacingAfterMethodDeclarationName, value); } } public int Space_AfterSemicolonsInForStatement { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceAfterSemicolonsInForStatement); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceAfterSemicolonsInForStatement, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceAfterSemicolonsInForStatement); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceAfterSemicolonsInForStatement, value); } } public int Space_AroundBinaryOperator { get { - var option = _workspace.Options.GetOption(CSharpFormattingOptions.SpacingAroundBinaryOperator); + var option = _workspace.Options.GetOption(CSharpFormattingOptions2.SpacingAroundBinaryOperator); return option == BinaryOperatorSpacingOptions.Single ? 1 : 0; } @@ -434,110 +434,110 @@ public int Space_AroundBinaryOperator { var option = value == 1 ? BinaryOperatorSpacingOptions.Single : BinaryOperatorSpacingOptions.Ignore; _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options - .WithChangedOption(CSharpFormattingOptions.SpacingAroundBinaryOperator, option))); + .WithChangedOption(CSharpFormattingOptions2.SpacingAroundBinaryOperator, option))); } } public int Space_BeforeBasesColon { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceBeforeColonInBaseTypeDeclaration); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceBeforeColonInBaseTypeDeclaration, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceBeforeColonInBaseTypeDeclaration); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceBeforeColonInBaseTypeDeclaration, value); } } public int Space_BeforeComma { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceBeforeComma); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceBeforeComma, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceBeforeComma); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceBeforeComma, value); } } public int Space_BeforeDot { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceBeforeDot); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceBeforeDot, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceBeforeDot); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceBeforeDot, value); } } public int Space_BeforeOpenSquare { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceBeforeOpenSquareBracket); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceBeforeOpenSquareBracket, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceBeforeOpenSquareBracket); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceBeforeOpenSquareBracket, value); } } public int Space_BeforeSemicolonsInForStatement { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceBeforeSemicolonsInForStatement); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceBeforeSemicolonsInForStatement, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceBeforeSemicolonsInForStatement); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceBeforeSemicolonsInForStatement, value); } } public int Space_BetweenEmptyMethodCallParentheses { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceBetweenEmptyMethodCallParentheses); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceBetweenEmptyMethodCallParentheses, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceBetweenEmptyMethodCallParentheses); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceBetweenEmptyMethodCallParentheses, value); } } public int Space_BetweenEmptyMethodDeclarationParentheses { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceBetweenEmptyMethodDeclarationParentheses); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceBetweenEmptyMethodDeclarationParentheses, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceBetweenEmptyMethodDeclarationParentheses); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceBetweenEmptyMethodDeclarationParentheses, value); } } public int Space_BetweenEmptySquares { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceBetweenEmptySquareBrackets); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceBetweenEmptySquareBrackets, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceBetweenEmptySquareBrackets); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceBetweenEmptySquareBrackets, value); } } public int Space_InControlFlowConstruct { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceAfterControlFlowStatementKeyword); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceAfterControlFlowStatementKeyword, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceAfterControlFlowStatementKeyword); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceAfterControlFlowStatementKeyword, value); } } public int Space_WithinCastParentheses { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceWithinCastParentheses); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceWithinCastParentheses, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceWithinCastParentheses); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceWithinCastParentheses, value); } } public int Space_WithinExpressionParentheses { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceWithinExpressionParentheses); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceWithinExpressionParentheses, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceWithinExpressionParentheses); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceWithinExpressionParentheses, value); } } public int Space_WithinMethodCallParentheses { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceWithinMethodCallParentheses); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceWithinMethodCallParentheses, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceWithinMethodCallParentheses); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceWithinMethodCallParentheses, value); } } public int Space_WithinMethodDeclarationParentheses { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceWithinMethodDeclarationParenthesis); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceWithinMethodDeclarationParenthesis, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceWithinMethodDeclarationParenthesis); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceWithinMethodDeclarationParenthesis, value); } } public int Space_WithinOtherParentheses { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceWithinOtherParentheses); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceWithinOtherParentheses, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceWithinOtherParentheses); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceWithinOtherParentheses, value); } } public int Space_WithinSquares { - get { return GetBooleanOption(CSharpFormattingOptions.SpaceWithinSquareBrackets); } - set { SetBooleanOption(CSharpFormattingOptions.SpaceWithinSquareBrackets, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpaceWithinSquareBrackets); } + set { SetBooleanOption(CSharpFormattingOptions2.SpaceWithinSquareBrackets, value); } } public string Style_PreferIntrinsicPredefinedTypeKeywordInDeclaration_CodeStyle { - get { return GetXmlOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration); } - set { SetXmlOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, value); } + get { return GetXmlOption(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration); } + set { SetXmlOption(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, value); } } public string Style_PreferIntrinsicPredefinedTypeKeywordInMemberAccess_CodeStyle { - get { return GetXmlOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess); } - set { SetXmlOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, value); } + get { return GetXmlOption(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess); } + set { SetXmlOption(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, value); } } public string Style_NamingPreferences @@ -562,26 +562,26 @@ public string Style_NamingPreferences public string Style_QualifyFieldAccess { - get { return GetXmlOption(CodeStyleOptions.QualifyFieldAccess); } - set { SetXmlOption(CodeStyleOptions.QualifyFieldAccess, value); } + get { return GetXmlOption(CodeStyleOptions2.QualifyFieldAccess); } + set { SetXmlOption(CodeStyleOptions2.QualifyFieldAccess, value); } } public string Style_QualifyPropertyAccess { - get { return GetXmlOption(CodeStyleOptions.QualifyPropertyAccess); } - set { SetXmlOption(CodeStyleOptions.QualifyPropertyAccess, value); } + get { return GetXmlOption(CodeStyleOptions2.QualifyPropertyAccess); } + set { SetXmlOption(CodeStyleOptions2.QualifyPropertyAccess, value); } } public string Style_QualifyMethodAccess { - get { return GetXmlOption(CodeStyleOptions.QualifyMethodAccess); } - set { SetXmlOption(CodeStyleOptions.QualifyMethodAccess, value); } + get { return GetXmlOption(CodeStyleOptions2.QualifyMethodAccess); } + set { SetXmlOption(CodeStyleOptions2.QualifyMethodAccess, value); } } public string Style_QualifyEventAccess { - get { return GetXmlOption(CodeStyleOptions.QualifyEventAccess); } - set { SetXmlOption(CodeStyleOptions.QualifyEventAccess, value); } + get { return GetXmlOption(CodeStyleOptions2.QualifyEventAccess); } + set { SetXmlOption(CodeStyleOptions2.QualifyEventAccess, value); } } public string Style_PreferThrowExpression @@ -592,26 +592,26 @@ public string Style_PreferThrowExpression public string Style_PreferObjectInitializer { - get { return GetXmlOption(CodeStyleOptions.PreferObjectInitializer); } - set { SetXmlOption(CodeStyleOptions.PreferObjectInitializer, value); } + get { return GetXmlOption(CodeStyleOptions2.PreferObjectInitializer); } + set { SetXmlOption(CodeStyleOptions2.PreferObjectInitializer, value); } } public string Style_PreferCollectionInitializer { - get { return GetXmlOption(CodeStyleOptions.PreferCollectionInitializer); } - set { SetXmlOption(CodeStyleOptions.PreferCollectionInitializer, value); } + get { return GetXmlOption(CodeStyleOptions2.PreferCollectionInitializer); } + set { SetXmlOption(CodeStyleOptions2.PreferCollectionInitializer, value); } } public string Style_PreferCoalesceExpression { - get { return GetXmlOption(CodeStyleOptions.PreferCoalesceExpression); } - set { SetXmlOption(CodeStyleOptions.PreferCoalesceExpression, value); } + get { return GetXmlOption(CodeStyleOptions2.PreferCoalesceExpression); } + set { SetXmlOption(CodeStyleOptions2.PreferCoalesceExpression, value); } } public string Style_PreferNullPropagation { - get { return GetXmlOption(CodeStyleOptions.PreferNullPropagation); } - set { SetXmlOption(CodeStyleOptions.PreferNullPropagation, value); } + get { return GetXmlOption(CodeStyleOptions2.PreferNullPropagation); } + set { SetXmlOption(CodeStyleOptions2.PreferNullPropagation, value); } } public string Style_PreferInlinedVariableDeclaration @@ -622,20 +622,20 @@ public string Style_PreferInlinedVariableDeclaration public string Style_PreferExplicitTupleNames { - get { return GetXmlOption(CodeStyleOptions.PreferExplicitTupleNames); } - set { SetXmlOption(CodeStyleOptions.PreferExplicitTupleNames, value); } + get { return GetXmlOption(CodeStyleOptions2.PreferExplicitTupleNames); } + set { SetXmlOption(CodeStyleOptions2.PreferExplicitTupleNames, value); } } public string Style_PreferInferredTupleNames { - get { return GetXmlOption(CodeStyleOptions.PreferInferredTupleNames); } - set { SetXmlOption(CodeStyleOptions.PreferInferredTupleNames, value); } + get { return GetXmlOption(CodeStyleOptions2.PreferInferredTupleNames); } + set { SetXmlOption(CodeStyleOptions2.PreferInferredTupleNames, value); } } public string Style_PreferInferredAnonymousTypeMemberNames { - get { return GetXmlOption(CodeStyleOptions.PreferInferredAnonymousTypeMemberNames); } - set { SetXmlOption(CodeStyleOptions.PreferInferredAnonymousTypeMemberNames, value); } + get { return GetXmlOption(CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames); } + set { SetXmlOption(CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames, value); } } [Obsolete("Use Style_UseImplicitTypeWherePossible, Style_UseImplicitTypeWhereApparent or Style_UseImplicitTypeForIntrinsicTypes", error: true)] @@ -731,76 +731,76 @@ public string Style_PreferBraces public string Style_PreferReadonly { - get { return GetXmlOption(CodeStyleOptions.PreferReadonly); } - set { SetXmlOption(CodeStyleOptions.PreferReadonly, value); } + get { return GetXmlOption(CodeStyleOptions2.PreferReadonly); } + set { SetXmlOption(CodeStyleOptions2.PreferReadonly, value); } } public int Wrapping_IgnoreSpacesAroundBinaryOperators { get { - return (int)_workspace.Options.GetOption(CSharpFormattingOptions.SpacingAroundBinaryOperator); + return (int)_workspace.Options.GetOption(CSharpFormattingOptions2.SpacingAroundBinaryOperator); } set { _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options - .WithChangedOption(CSharpFormattingOptions.SpacingAroundBinaryOperator, value))); + .WithChangedOption(CSharpFormattingOptions2.SpacingAroundBinaryOperator, value))); } } public int Wrapping_IgnoreSpacesAroundVariableDeclaration { - get { return GetBooleanOption(CSharpFormattingOptions.SpacesIgnoreAroundVariableDeclaration); } - set { SetBooleanOption(CSharpFormattingOptions.SpacesIgnoreAroundVariableDeclaration, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.SpacesIgnoreAroundVariableDeclaration); } + set { SetBooleanOption(CSharpFormattingOptions2.SpacesIgnoreAroundVariableDeclaration, value); } } public int Wrapping_KeepStatementsOnSingleLine { - get { return GetBooleanOption(CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine); } - set { SetBooleanOption(CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.WrappingKeepStatementsOnSingleLine); } + set { SetBooleanOption(CSharpFormattingOptions2.WrappingKeepStatementsOnSingleLine, value); } } public int Wrapping_PreserveSingleLine { - get { return GetBooleanOption(CSharpFormattingOptions.WrappingPreserveSingleLine); } - set { SetBooleanOption(CSharpFormattingOptions.WrappingPreserveSingleLine, value); } + get { return GetBooleanOption(CSharpFormattingOptions2.WrappingPreserveSingleLine); } + set { SetBooleanOption(CSharpFormattingOptions2.WrappingPreserveSingleLine, value); } } - private int GetBooleanOption(Option key) + private int GetBooleanOption(Option2 key) { return _workspace.Options.GetOption(key) ? 1 : 0; } - private int GetBooleanOption(PerLanguageOption key) + private int GetBooleanOption(PerLanguageOption2 key) { return _workspace.Options.GetOption(key, LanguageNames.CSharp) ? 1 : 0; } - private T GetOption(PerLanguageOption key) + private T GetOption(PerLanguageOption2 key) { return _workspace.Options.GetOption(key, LanguageNames.CSharp); } - private void SetBooleanOption(Option key, int value) + private void SetBooleanOption(Option2 key, int value) { _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options .WithChangedOption(key, value != 0))); } - private void SetBooleanOption(PerLanguageOption key, int value) + private void SetBooleanOption(PerLanguageOption2 key, int value) { _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options .WithChangedOption(key, LanguageNames.CSharp, value != 0))); } - private void SetOption(PerLanguageOption key, T value) + private void SetOption(PerLanguageOption2 key, T value) { _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options .WithChangedOption(key, LanguageNames.CSharp, value))); } - private int GetBooleanOption(PerLanguageOption key) + private int GetBooleanOption(PerLanguageOption2 key) { var option = _workspace.Options.GetOption(key, LanguageNames.CSharp); if (!option.HasValue) @@ -811,33 +811,33 @@ private int GetBooleanOption(PerLanguageOption key) return option.Value ? 1 : 0; } - private string GetXmlOption(Option> option) + private string GetXmlOption(Option2> option) { return _workspace.Options.GetOption(option).ToXElement().ToString(); } - private void SetBooleanOption(PerLanguageOption key, int value) + private void SetBooleanOption(PerLanguageOption2 key, int value) { var boolValue = (value < 0) ? (bool?)null : (value > 0); _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options .WithChangedOption(key, LanguageNames.CSharp, boolValue))); } - private string GetXmlOption(PerLanguageOption> option) + private string GetXmlOption(PerLanguageOption2> option) { return _workspace.Options.GetOption(option, LanguageNames.CSharp).ToXElement().ToString(); } - private void SetXmlOption(Option> option, string value) + private void SetXmlOption(Option2> option, string value) { - var convertedValue = CodeStyleOption.FromXElement(XElement.Parse(value)); + var convertedValue = CodeStyleOption2.FromXElement(XElement.Parse(value)); _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options .WithChangedOption(option, convertedValue))); } - private void SetXmlOption(PerLanguageOption> option, string value) + private void SetXmlOption(PerLanguageOption2> option, string value) { - var convertedValue = CodeStyleOption.FromXElement(XElement.Parse(value)); + var convertedValue = CodeStyleOption2.FromXElement(XElement.Parse(value)); _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options .WithChangedOption(option, LanguageNames.CSharp, convertedValue))); } diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/CodeStylePage.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/CodeStylePage.cs index 16f5675c91e0d..f22f638b53f42 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/CodeStylePage.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/CodeStylePage.cs @@ -32,8 +32,8 @@ protected override AbstractOptionPageControl CreateOptionPage(IServiceProvider s { var builder = ArrayBuilder<(string, ImmutableArray)>.GetInstance(); builder.AddRange(GridOptionPreviewControl.GetLanguageAgnosticEditorConfigOptions()); - builder.Add((CSharpVSResources.CSharp_Coding_Conventions, CSharpCodeStyleOptions.AllOptions)); - builder.Add((CSharpVSResources.CSharp_Formatting_Rules, CSharpFormattingOptions.AllOptions)); + builder.Add((CSharpVSResources.CSharp_Coding_Conventions, CSharpCodeStyleOptions.AllOptions.As())); + builder.Add((CSharpVSResources.CSharp_Formatting_Rules, CSharpFormattingOptions2.AllOptions.As())); return builder.ToImmutableAndFree(); } diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/FormattingOptionPageControl.xaml.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/FormattingOptionPageControl.xaml.cs index ba51637f3540e..32d68f9a56919 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/FormattingOptionPageControl.xaml.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/FormattingOptionPageControl.xaml.cs @@ -34,7 +34,7 @@ public FormattingOptionPageControl(OptionStore optionStore) : base(optionStore) BindToOption(FormatWhenTypingCheckBox, FeatureOnOffOptions.AutoFormattingOnTyping, LanguageNames.CSharp); BindToOption(FormatOnCloseBraceCheckBox, FeatureOnOffOptions.AutoFormattingOnCloseBrace, LanguageNames.CSharp); BindToOption(FormatOnSemicolonCheckBox, FeatureOnOffOptions.AutoFormattingOnSemicolon, LanguageNames.CSharp); - BindToOption(FormatOnReturnCheckBox, FormattingOptions.AutoFormattingOnReturn, LanguageNames.CSharp); + BindToOption(FormatOnReturnCheckBox, FormattingOptions2.AutoFormattingOnReturn, LanguageNames.CSharp); BindToOption(FormatOnPasteCheckBox, FeatureOnOffOptions.FormatOnPaste, LanguageNames.CSharp); } } diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs index 3cf6989c6130d..54ae9633867c1 100644 --- a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs +++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs @@ -1634,13 +1634,13 @@ internal StyleViewModel(OptionStore optionStore, IServiceProvider serviceProvide new CodeStylePreference(CSharpVSResources.Prefer_explicit_type, isChecked: false), }; - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyFieldAccess, CSharpVSResources.Qualify_field_access_with_this, s_fieldDeclarationPreviewTrue, s_fieldDeclarationPreviewFalse, this, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyPropertyAccess, CSharpVSResources.Qualify_property_access_with_this, s_propertyDeclarationPreviewTrue, s_propertyDeclarationPreviewFalse, this, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyMethodAccess, CSharpVSResources.Qualify_method_access_with_this, s_methodDeclarationPreviewTrue, s_methodDeclarationPreviewFalse, this, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyEventAccess, CSharpVSResources.Qualify_event_access_with_this, s_eventDeclarationPreviewTrue, s_eventDeclarationPreviewFalse, this, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.QualifyFieldAccess, CSharpVSResources.Qualify_field_access_with_this, s_fieldDeclarationPreviewTrue, s_fieldDeclarationPreviewFalse, this, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.QualifyPropertyAccess, CSharpVSResources.Qualify_property_access_with_this, s_propertyDeclarationPreviewTrue, s_propertyDeclarationPreviewFalse, this, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.QualifyMethodAccess, CSharpVSResources.Qualify_method_access_with_this, s_methodDeclarationPreviewTrue, s_methodDeclarationPreviewFalse, this, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.QualifyEventAccess, CSharpVSResources.Qualify_event_access_with_this, s_eventDeclarationPreviewTrue, s_eventDeclarationPreviewFalse, this, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, ServicesVSResources.For_locals_parameters_and_members, s_intrinsicPreviewDeclarationTrue, s_intrinsicPreviewDeclarationFalse, this, optionStore, predefinedTypesGroupTitle, predefinedTypesPreferences)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, ServicesVSResources.For_member_access_expressions, s_intrinsicPreviewMemberAccessTrue, s_intrinsicPreviewMemberAccessFalse, this, optionStore, predefinedTypesGroupTitle, predefinedTypesPreferences)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, ServicesVSResources.For_locals_parameters_and_members, s_intrinsicPreviewDeclarationTrue, s_intrinsicPreviewDeclarationFalse, this, optionStore, predefinedTypesGroupTitle, predefinedTypesPreferences)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, ServicesVSResources.For_member_access_expressions, s_intrinsicPreviewMemberAccessTrue, s_intrinsicPreviewMemberAccessFalse, this, optionStore, predefinedTypesGroupTitle, predefinedTypesPreferences)); // Use var CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.VarForBuiltInTypes, CSharpVSResources.For_built_in_types, s_varForIntrinsicsPreviewTrue, s_varForIntrinsicsPreviewFalse, this, optionStore, varGroupTitle, typeStylePreferences)); @@ -1649,26 +1649,26 @@ internal StyleViewModel(OptionStore optionStore, IServiceProvider serviceProvide // Code block AddBracesOptions(optionStore, codeBlockPreferencesGroupTitle); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferAutoProperties, ServicesVSResources.analyzer_Prefer_auto_properties, s_preferAutoProperties, s_preferAutoProperties, this, optionStore, codeBlockPreferencesGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferAutoProperties, ServicesVSResources.analyzer_Prefer_auto_properties, s_preferAutoProperties, s_preferAutoProperties, this, optionStore, codeBlockPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferSimpleUsingStatement, ServicesVSResources.Prefer_simple_using_statement, s_preferSimpleUsingStatement, s_preferSimpleUsingStatement, this, optionStore, codeBlockPreferencesGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferSystemHashCode, ServicesVSResources.Prefer_System_HashCode_in_GetHashCode, s_preferSystemHashCode, s_preferSystemHashCode, this, optionStore, codeBlockPreferencesGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferSystemHashCode, ServicesVSResources.Prefer_System_HashCode_in_GetHashCode, s_preferSystemHashCode, s_preferSystemHashCode, this, optionStore, codeBlockPreferencesGroupTitle)); AddParenthesesOptions(OptionStore); // Expression preferences - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferObjectInitializer, ServicesVSResources.Prefer_object_initializer, s_preferObjectInitializer, s_preferObjectInitializer, this, optionStore, expressionPreferencesGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferCollectionInitializer, ServicesVSResources.Prefer_collection_initializer, s_preferCollectionInitializer, s_preferCollectionInitializer, this, optionStore, expressionPreferencesGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferObjectInitializer, ServicesVSResources.Prefer_object_initializer, s_preferObjectInitializer, s_preferObjectInitializer, this, optionStore, expressionPreferencesGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferCollectionInitializer, ServicesVSResources.Prefer_collection_initializer, s_preferCollectionInitializer, s_preferCollectionInitializer, this, optionStore, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferSwitchExpression, CSharpVSResources.Prefer_switch_expression, s_preferSwitchExpression, s_preferSwitchExpression, this, optionStore, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferPatternMatchingOverIsWithCastCheck, CSharpVSResources.Prefer_pattern_matching_over_is_with_cast_check, s_preferPatternMatchingOverIsWithCastCheck, s_preferPatternMatchingOverIsWithCastCheck, this, optionStore, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferPatternMatchingOverAsWithNullCheck, CSharpVSResources.Prefer_pattern_matching_over_as_with_null_check, s_preferPatternMatchingOverAsWithNullCheck, s_preferPatternMatchingOverAsWithNullCheck, this, optionStore, expressionPreferencesGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferConditionalExpressionOverAssignment, ServicesVSResources.Prefer_conditional_expression_over_if_with_assignments, s_preferConditionalExpressionOverIfWithAssignments, s_preferConditionalExpressionOverIfWithAssignments, this, optionStore, expressionPreferencesGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferConditionalExpressionOverReturn, ServicesVSResources.Prefer_conditional_expression_over_if_with_returns, s_preferConditionalExpressionOverIfWithReturns, s_preferConditionalExpressionOverIfWithReturns, this, optionStore, expressionPreferencesGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferExplicitTupleNames, ServicesVSResources.Prefer_explicit_tuple_name, s_preferExplicitTupleName, s_preferExplicitTupleName, this, optionStore, expressionPreferencesGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferConditionalExpressionOverAssignment, ServicesVSResources.Prefer_conditional_expression_over_if_with_assignments, s_preferConditionalExpressionOverIfWithAssignments, s_preferConditionalExpressionOverIfWithAssignments, this, optionStore, expressionPreferencesGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferConditionalExpressionOverReturn, ServicesVSResources.Prefer_conditional_expression_over_if_with_returns, s_preferConditionalExpressionOverIfWithReturns, s_preferConditionalExpressionOverIfWithReturns, this, optionStore, expressionPreferencesGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferExplicitTupleNames, ServicesVSResources.Prefer_explicit_tuple_name, s_preferExplicitTupleName, s_preferExplicitTupleName, this, optionStore, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferSimpleDefaultExpression, ServicesVSResources.Prefer_simple_default_expression, s_preferSimpleDefaultExpression, s_preferSimpleDefaultExpression, this, optionStore, expressionPreferencesGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferInferredTupleNames, ServicesVSResources.Prefer_inferred_tuple_names, s_preferInferredTupleName, s_preferInferredTupleName, this, optionStore, expressionPreferencesGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferInferredAnonymousTypeMemberNames, ServicesVSResources.Prefer_inferred_anonymous_type_member_names, s_preferInferredAnonymousTypeMemberName, s_preferInferredAnonymousTypeMemberName, this, optionStore, expressionPreferencesGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferInferredTupleNames, ServicesVSResources.Prefer_inferred_tuple_names, s_preferInferredTupleName, s_preferInferredTupleName, this, optionStore, expressionPreferencesGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames, ServicesVSResources.Prefer_inferred_anonymous_type_member_names, s_preferInferredAnonymousTypeMemberName, s_preferInferredAnonymousTypeMemberName, this, optionStore, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferLocalOverAnonymousFunction, ServicesVSResources.Prefer_local_function_over_anonymous_function, s_preferLocalFunctionOverAnonymousFunction, s_preferLocalFunctionOverAnonymousFunction, this, optionStore, expressionPreferencesGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferCompoundAssignment, ServicesVSResources.Prefer_compound_assignments, s_preferCompoundAssignments, s_preferCompoundAssignments, this, optionStore, expressionPreferencesGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferCompoundAssignment, ServicesVSResources.Prefer_compound_assignments, s_preferCompoundAssignments, s_preferCompoundAssignments, this, optionStore, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferIndexOperator, ServicesVSResources.Prefer_index_operator, s_preferIndexOperator, s_preferIndexOperator, this, optionStore, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferRangeOperator, ServicesVSResources.Prefer_range_operator, s_preferRangeOperator, s_preferRangeOperator, this, optionStore, expressionPreferencesGroupTitle)); @@ -1683,9 +1683,9 @@ internal StyleViewModel(OptionStore optionStore, IServiceProvider serviceProvide // Null preferences. CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferThrowExpression, CSharpVSResources.Prefer_throw_expression, s_preferThrowExpression, s_preferThrowExpression, this, optionStore, nullCheckingGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferConditionalDelegateCall, CSharpVSResources.Prefer_conditional_delegate_call, s_preferConditionalDelegateCall, s_preferConditionalDelegateCall, this, optionStore, nullCheckingGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferCoalesceExpression, ServicesVSResources.Prefer_coalesce_expression, s_preferCoalesceExpression, s_preferCoalesceExpression, this, optionStore, nullCheckingGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferNullPropagation, ServicesVSResources.Prefer_null_propagation, s_preferNullPropagation, s_preferNullPropagation, this, optionStore, nullCheckingGroupTitle)); - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferIsNullCheckOverReferenceEqualityMethod, CSharpVSResources.Prefer_is_null_for_reference_equality_checks, s_preferIsNullOverReferenceEquals, s_preferIsNullOverReferenceEquals, this, optionStore, nullCheckingGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferCoalesceExpression, ServicesVSResources.Prefer_coalesce_expression, s_preferCoalesceExpression, s_preferCoalesceExpression, this, optionStore, nullCheckingGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferNullPropagation, ServicesVSResources.Prefer_null_propagation, s_preferNullPropagation, s_preferNullPropagation, this, optionStore, nullCheckingGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferIsNullCheckOverReferenceEqualityMethod, CSharpVSResources.Prefer_is_null_for_reference_equality_checks, s_preferIsNullOverReferenceEquals, s_preferIsNullOverReferenceEquals, this, optionStore, nullCheckingGroupTitle)); // Using directive preferences. CodeStyleItems.Add(new EnumCodeStyleOptionViewModel( @@ -1694,7 +1694,7 @@ internal StyleViewModel(OptionStore optionStore, IServiceProvider serviceProvide s_usingDirectivePlacement, this, optionStore, usingsGroupTitle, usingDirectivePlacementPreferences)); // Modifier preferences. - CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferReadonly, ServicesVSResources.Prefer_readonly_fields, s_preferReadonly, s_preferReadonly, this, optionStore, modifierGroupTitle)); + CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferReadonly, ServicesVSResources.Prefer_readonly_fields, s_preferReadonly, s_preferReadonly, this, optionStore, modifierGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferStaticLocalFunction, ServicesVSResources.Prefer_static_local_functions, s_preferStaticLocalFunction, s_preferStaticLocalFunction, this, optionStore, modifierGroupTitle)); // Parameter preferences @@ -1704,25 +1704,25 @@ internal StyleViewModel(OptionStore optionStore, IServiceProvider serviceProvide private void AddParenthesesOptions(OptionStore optionStore) { AddParenthesesOption( - LanguageNames.CSharp, optionStore, CodeStyleOptions.ArithmeticBinaryParentheses, + LanguageNames.CSharp, optionStore, CodeStyleOptions2.ArithmeticBinaryParentheses, CSharpVSResources.In_arithmetic_binary_operators, new[] { s_arithmeticBinaryAlwaysForClarity, s_arithmeticBinaryNeverIfUnnecessary }, defaultAddForClarity: true); AddParenthesesOption( - LanguageNames.CSharp, optionStore, CodeStyleOptions.OtherBinaryParentheses, + LanguageNames.CSharp, optionStore, CodeStyleOptions2.OtherBinaryParentheses, CSharpVSResources.In_other_binary_operators, new[] { s_otherBinaryAlwaysForClarity, s_otherBinaryNeverIfUnnecessary }, defaultAddForClarity: true); AddParenthesesOption( - LanguageNames.CSharp, optionStore, CodeStyleOptions.RelationalBinaryParentheses, + LanguageNames.CSharp, optionStore, CodeStyleOptions2.RelationalBinaryParentheses, CSharpVSResources.In_relational_binary_operators, new[] { s_relationalBinaryAlwaysForClarity, s_relationalBinaryNeverIfUnnecessary }, defaultAddForClarity: true); AddParenthesesOption( - LanguageNames.CSharp, optionStore, CodeStyleOptions.OtherParentheses, + LanguageNames.CSharp, optionStore, CodeStyleOptions2.OtherParentheses, ServicesVSResources.In_other_operators, new[] { s_otherParenthesesAlwaysForClarity, s_otherParenthesesNeverIfUnnecessary }, defaultAddForClarity: false); diff --git a/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPaneService.cs b/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPaneService.cs index d557f1d3bf12b..ebcbfecd2241a 100644 --- a/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPaneService.cs +++ b/src/VisualStudio/Core/Def/Implementation/PreviewPane/PreviewPaneService.cs @@ -126,7 +126,7 @@ private Guid GetOptionPageGuidForOptionName(string optionName, string optionLang return Guid.Parse(Guids.VisualBasicOptionPageNamingStyleIdString); } } - else if (optionName == nameof(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration)) + else if (optionName == nameof(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration)) { if (optionLanguage == LanguageNames.CSharp) { diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioNavigationOptions.cs b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioNavigationOptions.cs index 008a40baed1dc..a8b0124619b8c 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioNavigationOptions.cs +++ b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioNavigationOptions.cs @@ -10,7 +10,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation { internal static class VisualStudioNavigationOptions { - public static readonly PerLanguageOption NavigateToObjectBrowser = new PerLanguageOption(nameof(VisualStudioNavigationOptions), nameof(NavigateToObjectBrowser), defaultValue: false, + public static readonly PerLanguageOption2 NavigateToObjectBrowser = new PerLanguageOption2(nameof(VisualStudioNavigationOptions), nameof(NavigateToObjectBrowser), defaultValue: false, storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.NavigateToObjectBrowser")); } } diff --git a/src/VisualStudio/Core/Impl/Options/AbstractOptionPageControl.cs b/src/VisualStudio/Core/Impl/Options/AbstractOptionPageControl.cs index bcadf4301ff5b..6d078809cce98 100644 --- a/src/VisualStudio/Core/Impl/Options/AbstractOptionPageControl.cs +++ b/src/VisualStudio/Core/Impl/Options/AbstractOptionPageControl.cs @@ -61,7 +61,7 @@ private void InitializeStyles() Resources.Add(typeof(ComboBox), comboBoxStyle); } - protected void BindToOption(CheckBox checkbox, Option optionKey) + private protected void BindToOption(CheckBox checkbox, Option2 optionKey) { var binding = new Binding() { @@ -74,7 +74,7 @@ protected void BindToOption(CheckBox checkbox, Option optionKey) _bindingExpressions.Add(bindingExpression); } - protected void BindToOption(CheckBox checkbox, PerLanguageOption optionKey, string languageName) + private protected void BindToOption(CheckBox checkbox, PerLanguageOption2 optionKey, string languageName) { var binding = new Binding() { @@ -87,7 +87,7 @@ protected void BindToOption(CheckBox checkbox, PerLanguageOption optionKey _bindingExpressions.Add(bindingExpression); } - protected void BindToOption(TextBox textBox, Option optionKey) + private protected void BindToOption(TextBox textBox, Option2 optionKey) { var binding = new Binding() { @@ -100,7 +100,7 @@ protected void BindToOption(TextBox textBox, Option optionKey) _bindingExpressions.Add(bindingExpression); } - protected void BindToOption(TextBox textBox, PerLanguageOption optionKey, string languageName) + private protected void BindToOption(TextBox textBox, PerLanguageOption2 optionKey, string languageName) { var binding = new Binding() { @@ -113,7 +113,7 @@ protected void BindToOption(TextBox textBox, PerLanguageOption optionKey, s _bindingExpressions.Add(bindingExpression); } - protected void BindToOption(ComboBox comboBox, Option optionKey) + private protected void BindToOption(ComboBox comboBox, Option2 optionKey) { var binding = new Binding() { @@ -127,7 +127,7 @@ protected void BindToOption(ComboBox comboBox, Option optionKey) _bindingExpressions.Add(bindingExpression); } - protected void BindToOption(ComboBox comboBox, PerLanguageOption optionKey, string languageName) + private protected void BindToOption(ComboBox comboBox, PerLanguageOption2 optionKey, string languageName) { var binding = new Binding() { @@ -141,7 +141,7 @@ protected void BindToOption(ComboBox comboBox, PerLanguageOption optionKey _bindingExpressions.Add(bindingExpression); } - protected void BindToOption(RadioButton radiobutton, PerLanguageOption optionKey, T optionValue, string languageName) + private protected void BindToOption(RadioButton radiobutton, PerLanguageOption2 optionKey, T optionValue, string languageName) { var binding = new Binding() { diff --git a/src/VisualStudio/Core/Impl/Options/AbstractOptionPreviewViewModel.cs b/src/VisualStudio/Core/Impl/Options/AbstractOptionPreviewViewModel.cs index 72b401d8fb450..c61c774fa3809 100644 --- a/src/VisualStudio/Core/Impl/Options/AbstractOptionPreviewViewModel.cs +++ b/src/VisualStudio/Core/Impl/Options/AbstractOptionPreviewViewModel.cs @@ -214,7 +214,7 @@ private void UpdateDocument(string text) protected void AddParenthesesOption( string language, OptionStore optionStore, - PerLanguageOption> languageOption, + PerLanguageOption2> languageOption, string title, string[] examples, bool defaultAddForClarity) { var preferences = new List(); @@ -249,7 +249,7 @@ protected void AddUnusedParameterOption(string language, OptionStore optionStore }; CodeStyleItems.Add(new EnumCodeStyleOptionViewModel( - CodeStyleOptions.UnusedParameters, language, + CodeStyleOptions2.UnusedParameters, language, ServicesVSResources.Avoid_unused_parameters, enumValues, examples, this, optionStore, title, unusedParameterPreferences)); diff --git a/src/VisualStudio/Core/Impl/Options/GridOptionPreviewControl.xaml.cs b/src/VisualStudio/Core/Impl/Options/GridOptionPreviewControl.xaml.cs index 678b062a24373..bd790facb47b2 100644 --- a/src/VisualStudio/Core/Impl/Options/GridOptionPreviewControl.xaml.cs +++ b/src/VisualStudio/Core/Impl/Options/GridOptionPreviewControl.xaml.cs @@ -56,8 +56,8 @@ internal GridOptionPreviewControl(IServiceProvider serviceProvider, internal static IEnumerable<(string feature, ImmutableArray options)> GetLanguageAgnosticEditorConfigOptions() { - yield return (WorkspacesResources.Core_EditorConfig_Options, FormattingOptions.AllOptions); - yield return (WorkspacesResources.dot_NET_Coding_Conventions, GenerationOptions.AllOptions.Concat(CodeStyleOptions.AllOptions)); + yield return (WorkspacesResources.Core_EditorConfig_Options, FormattingOptions2.AllOptions.As()); + yield return (WorkspacesResources.dot_NET_Coding_Conventions, GenerationOptions.AllOptions.AddRange(CodeStyleOptions2.AllOptions)); } private void LearnMoreHyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) diff --git a/src/VisualStudio/Core/Impl/Options/OptionBinding.cs b/src/VisualStudio/Core/Impl/Options/OptionBinding.cs index 6e5e9873c3ba8..50a902120b5e6 100644 --- a/src/VisualStudio/Core/Impl/Options/OptionBinding.cs +++ b/src/VisualStudio/Core/Impl/Options/OptionBinding.cs @@ -10,11 +10,11 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options internal class OptionBinding : INotifyPropertyChanged { private readonly OptionStore _optionStore; - private readonly Option _key; + private readonly Option2 _key; public event PropertyChangedEventHandler PropertyChanged; - public OptionBinding(OptionStore optionStore, Option key) + public OptionBinding(OptionStore optionStore, Option2 key) { _optionStore = optionStore; _key = key; diff --git a/src/VisualStudio/Core/Impl/Options/OptionStore.cs b/src/VisualStudio/Core/Impl/Options/OptionStore.cs index db97232e7e6fb..a9730ec1d9448 100644 --- a/src/VisualStudio/Core/Impl/Options/OptionStore.cs +++ b/src/VisualStudio/Core/Impl/Options/OptionStore.cs @@ -27,7 +27,9 @@ public OptionStore(OptionSet optionSet, IEnumerable registeredOptions) public object GetOption(OptionKey optionKey) => _optionSet.GetOption(optionKey); public T GetOption(Option option) => _optionSet.GetOption(option); + internal T GetOption(Option2 option) => _optionSet.GetOption(option); public T GetOption(PerLanguageOption option, string language) => _optionSet.GetOption(option, language); + internal T GetOption(PerLanguageOption2 option, string language) => _optionSet.GetOption(option, language); public OptionSet GetOptions() => _optionSet; public void SetOption(OptionKey optionKey, object value) @@ -44,6 +46,13 @@ public void SetOption(Option option, T value) OnOptionChanged(new OptionKey(option)); } + internal void SetOption(Option2 option, T value) + { + _optionSet = _optionSet.WithChangedOption(option, value); + + OnOptionChanged(new OptionKey(option)); + } + public void SetOption(PerLanguageOption option, string language, T value) { _optionSet = _optionSet.WithChangedOption(option, language, value); @@ -51,6 +60,13 @@ public void SetOption(PerLanguageOption option, string language, T value) OnOptionChanged(new OptionKey(option, language)); } + internal void SetOption(PerLanguageOption2 option, string language, T value) + { + _optionSet = _optionSet.WithChangedOption(option, language, value); + + OnOptionChanged(new OptionKey(option, language)); + } + public IEnumerable GetRegisteredOptions() { return _registeredOptions; diff --git a/src/VisualStudio/Core/Impl/Options/PerLanguageOptionBinding.cs b/src/VisualStudio/Core/Impl/Options/PerLanguageOptionBinding.cs index 109dffd3879a4..91c14ed192e12 100644 --- a/src/VisualStudio/Core/Impl/Options/PerLanguageOptionBinding.cs +++ b/src/VisualStudio/Core/Impl/Options/PerLanguageOptionBinding.cs @@ -10,12 +10,12 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options internal class PerLanguageOptionBinding : INotifyPropertyChanged { private readonly OptionStore _optionStore; - private readonly PerLanguageOption _key; + private readonly PerLanguageOption2 _key; private readonly string _languageName; public event PropertyChangedEventHandler PropertyChanged; - public PerLanguageOptionBinding(OptionStore optionStore, PerLanguageOption key, string languageName) + public PerLanguageOptionBinding(OptionStore optionStore, PerLanguageOption2 key, string languageName) { _optionStore = optionStore; _key = key; diff --git a/src/VisualStudio/Core/Impl/Options/Style/EnumCodeStyleOptionViewModel.cs b/src/VisualStudio/Core/Impl/Options/Style/EnumCodeStyleOptionViewModel.cs index 50b0ae929dd7c..8ebd3eaafe488 100644 --- a/src/VisualStudio/Core/Impl/Options/Style/EnumCodeStyleOptionViewModel.cs +++ b/src/VisualStudio/Core/Impl/Options/Style/EnumCodeStyleOptionViewModel.cs @@ -36,7 +36,7 @@ static EnumCodeStyleOptionViewModel() private NotificationOptionViewModel _selectedNotificationPreference; public EnumCodeStyleOptionViewModel( - PerLanguageOption> option, + PerLanguageOption2> option, string language, string description, T[] enumValues, @@ -51,7 +51,7 @@ public EnumCodeStyleOptionViewModel( } public EnumCodeStyleOptionViewModel( - Option> option, + Option2> option, string description, T[] enumValues, string[] previews, diff --git a/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject.vb b/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject.vb index 268242208faf1..4e83ea1e77c9f 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/AutomationObject.vb @@ -143,127 +143,127 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options Public Property Style_PreferIntrinsicPredefinedTypeKeywordInDeclaration_CodeStyle As String Get - Return GetXmlOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration) + Return GetXmlOption(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, value) + SetXmlOption(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, value) End Set End Property Public Property Style_PreferIntrinsicPredefinedTypeKeywordInMemberAccess_CodeStyle As String Get - Return GetXmlOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess) + Return GetXmlOption(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, value) + SetXmlOption(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, value) End Set End Property Public Property Style_QualifyFieldAccess As String Get - Return GetXmlOption(CodeStyleOptions.QualifyFieldAccess) + Return GetXmlOption(CodeStyleOptions2.QualifyFieldAccess) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.QualifyFieldAccess, value) + SetXmlOption(CodeStyleOptions2.QualifyFieldAccess, value) End Set End Property Public Property Style_QualifyPropertyAccess As String Get - Return GetXmlOption(CodeStyleOptions.QualifyPropertyAccess) + Return GetXmlOption(CodeStyleOptions2.QualifyPropertyAccess) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.QualifyPropertyAccess, value) + SetXmlOption(CodeStyleOptions2.QualifyPropertyAccess, value) End Set End Property Public Property Style_QualifyMethodAccess As String Get - Return GetXmlOption(CodeStyleOptions.QualifyMethodAccess) + Return GetXmlOption(CodeStyleOptions2.QualifyMethodAccess) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.QualifyMethodAccess, value) + SetXmlOption(CodeStyleOptions2.QualifyMethodAccess, value) End Set End Property Public Property Style_QualifyEventAccess As String Get - Return GetXmlOption(CodeStyleOptions.QualifyEventAccess) + Return GetXmlOption(CodeStyleOptions2.QualifyEventAccess) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.QualifyEventAccess, value) + SetXmlOption(CodeStyleOptions2.QualifyEventAccess, value) End Set End Property Public Property Style_PreferObjectInitializer As String Get - Return GetXmlOption(CodeStyleOptions.PreferObjectInitializer) + Return GetXmlOption(CodeStyleOptions2.PreferObjectInitializer) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.PreferObjectInitializer, value) + SetXmlOption(CodeStyleOptions2.PreferObjectInitializer, value) End Set End Property Public Property Style_PreferCollectionInitializer As String Get - Return GetXmlOption(CodeStyleOptions.PreferCollectionInitializer) + Return GetXmlOption(CodeStyleOptions2.PreferCollectionInitializer) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.PreferCollectionInitializer, value) + SetXmlOption(CodeStyleOptions2.PreferCollectionInitializer, value) End Set End Property Public Property Style_PreferCoalesceExpression As String Get - Return GetXmlOption(CodeStyleOptions.PreferCoalesceExpression) + Return GetXmlOption(CodeStyleOptions2.PreferCoalesceExpression) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.PreferCoalesceExpression, value) + SetXmlOption(CodeStyleOptions2.PreferCoalesceExpression, value) End Set End Property Public Property Style_PreferNullPropagation As String Get - Return GetXmlOption(CodeStyleOptions.PreferNullPropagation) + Return GetXmlOption(CodeStyleOptions2.PreferNullPropagation) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.PreferNullPropagation, value) + SetXmlOption(CodeStyleOptions2.PreferNullPropagation, value) End Set End Property Public Property Style_PreferInferredTupleNames As String Get - Return GetXmlOption(CodeStyleOptions.PreferInferredTupleNames) + Return GetXmlOption(CodeStyleOptions2.PreferInferredTupleNames) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.PreferInferredTupleNames, value) + SetXmlOption(CodeStyleOptions2.PreferInferredTupleNames, value) End Set End Property Public Property Style_PreferInferredAnonymousTypeMemberNames As String Get - Return GetXmlOption(CodeStyleOptions.PreferInferredAnonymousTypeMemberNames) + Return GetXmlOption(CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.PreferInferredAnonymousTypeMemberNames, value) + SetXmlOption(CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames, value) End Set End Property Public Property Style_PreferExplicitTupleNames As String Get - Return GetXmlOption(CodeStyleOptions.PreferExplicitTupleNames) + Return GetXmlOption(CodeStyleOptions2.PreferExplicitTupleNames) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.PreferExplicitTupleNames, value) + SetXmlOption(CodeStyleOptions2.PreferExplicitTupleNames, value) End Set End Property Public Property Style_PreferReadonly As String Get - Return GetXmlOption(CodeStyleOptions.PreferReadonly) + Return GetXmlOption(CodeStyleOptions2.PreferReadonly) End Get Set(value As String) - SetXmlOption(CodeStyleOptions.PreferReadonly, value) + SetXmlOption(CodeStyleOptions2.PreferReadonly, value) End Set End Property @@ -303,20 +303,20 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options End Set End Property - Private Function GetBooleanOption(key As [PerLanguageOption](Of Boolean)) As Boolean + Private Function GetBooleanOption(key As [PerLanguageOption2](Of Boolean)) As Boolean Return _workspace.Options.GetOption(key, LanguageNames.VisualBasic) End Function - Private Function GetXmlOption(key As PerLanguageOption(Of CodeStyleOption(Of Boolean))) As String + Private Function GetXmlOption(key As PerLanguageOption2(Of CodeStyleOption2(Of Boolean))) As String Return _workspace.Options.GetOption(key, LanguageNames.VisualBasic).ToXElement().ToString() End Function - Private Sub SetBooleanOption(key As [PerLanguageOption](Of Boolean), value As Boolean) + Private Sub SetBooleanOption(key As [PerLanguageOption2](Of Boolean), value As Boolean) _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options _ .WithChangedOption(key, LanguageNames.VisualBasic, value))) End Sub - Private Function GetBooleanOption(key As PerLanguageOption(Of Boolean?)) As Integer + Private Function GetBooleanOption(key As PerLanguageOption2(Of Boolean?)) As Integer Dim [option] = _workspace.Options.GetOption(key, LanguageNames.VisualBasic) If Not [option].HasValue Then Return -1 @@ -325,14 +325,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options Return If([option].Value, 1, 0) End Function - Private Sub SetBooleanOption(key As PerLanguageOption(Of Boolean?), value As Integer) + Private Sub SetBooleanOption(key As PerLanguageOption2(Of Boolean?), value As Integer) Dim boolValue As Boolean? = If(value < 0, Nothing, value > 0) _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options _ .WithChangedOption(key, LanguageNames.VisualBasic, boolValue))) End Sub - Private Sub SetXmlOption(key As PerLanguageOption(Of CodeStyleOption(Of Boolean)), value As String) - Dim convertedValue = CodeStyleOption(Of Boolean).FromXElement(XElement.Parse(value)) + Private Sub SetXmlOption(key As PerLanguageOption2(Of CodeStyleOption2(Of Boolean)), value As String) + Dim convertedValue = CodeStyleOption2(Of Boolean).FromXElement(XElement.Parse(value)) _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options _ .WithChangedOption(key, LanguageNames.VisualBasic, convertedValue))) End Sub diff --git a/src/VisualStudio/VisualBasic/Impl/Options/Formatting/CodeStylePage.vb b/src/VisualStudio/VisualBasic/Impl/Options/Formatting/CodeStylePage.vb index 8704eb35f77ec..496560e9f53bb 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/Formatting/CodeStylePage.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/Formatting/CodeStylePage.vb @@ -26,7 +26,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options.Formatting Private Shared Function GetEditorConfigOptions() As ImmutableArray(Of (String, ImmutableArray(Of IOption))) Dim builder = ArrayBuilder(Of (String, ImmutableArray(Of IOption))).GetInstance() builder.AddRange(GridOptionPreviewControl.GetLanguageAgnosticEditorConfigOptions()) - builder.Add((BasicVSResources.VB_Coding_Conventions, VisualBasicCodeStyleOptions.AllOptions)) + builder.Add((BasicVSResources.VB_Coding_Conventions, VisualBasicCodeStyleOptions.AllOptions.As(Of IOption))) Return builder.ToImmutableAndFree() End Function diff --git a/src/VisualStudio/VisualBasic/Impl/Options/StyleViewModel.vb b/src/VisualStudio/VisualBasic/Impl/Options/StyleViewModel.vb index 3ad3dea02a962..e95b2bf51e2a5 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/StyleViewModel.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/StyleViewModel.vb @@ -674,40 +674,40 @@ End Class Dim parameterPreferencesGroupTitle = ServicesVSResources.Parameter_preferences_colon ' qualify with Me. group - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyFieldAccess, BasicVSResources.Qualify_field_access_with_Me, s_fieldDeclarationPreviewTrue, s_fieldDeclarationPreviewFalse, Me, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyPropertyAccess, BasicVSResources.Qualify_property_access_with_Me, s_propertyDeclarationPreviewTrue, s_propertyDeclarationPreviewFalse, Me, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyMethodAccess, BasicVSResources.Qualify_method_access_with_Me, s_methodDeclarationPreviewTrue, s_methodDeclarationPreviewFalse, Me, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyEventAccess, BasicVSResources.Qualify_event_access_with_Me, s_eventDeclarationPreviewTrue, s_eventDeclarationPreviewFalse, Me, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.QualifyFieldAccess, BasicVSResources.Qualify_field_access_with_Me, s_fieldDeclarationPreviewTrue, s_fieldDeclarationPreviewFalse, Me, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.QualifyPropertyAccess, BasicVSResources.Qualify_property_access_with_Me, s_propertyDeclarationPreviewTrue, s_propertyDeclarationPreviewFalse, Me, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.QualifyMethodAccess, BasicVSResources.Qualify_method_access_with_Me, s_methodDeclarationPreviewTrue, s_methodDeclarationPreviewFalse, Me, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.QualifyEventAccess, BasicVSResources.Qualify_event_access_with_Me, s_eventDeclarationPreviewTrue, s_eventDeclarationPreviewFalse, Me, optionStore, qualifyGroupTitle, qualifyMemberAccessPreferences)) ' predefined or framework type group - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, ServicesVSResources.For_locals_parameters_and_members, _intrinsicDeclarationPreviewTrue, _intrinsicDeclarationPreviewFalse, Me, optionStore, predefinedTypesGroupTitle, predefinedTypesPreferences)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, ServicesVSResources.For_member_access_expressions, _intrinsicMemberAccessPreviewTrue, _intrinsicMemberAccessPreviewFalse, Me, optionStore, predefinedTypesGroupTitle, predefinedTypesPreferences)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, ServicesVSResources.For_locals_parameters_and_members, _intrinsicDeclarationPreviewTrue, _intrinsicDeclarationPreviewFalse, Me, optionStore, predefinedTypesGroupTitle, predefinedTypesPreferences)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, ServicesVSResources.For_member_access_expressions, _intrinsicMemberAccessPreviewTrue, _intrinsicMemberAccessPreviewFalse, Me, optionStore, predefinedTypesGroupTitle, predefinedTypesPreferences)) AddParenthesesOptions(optionStore) ' Code block - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferAutoProperties, ServicesVSResources.analyzer_Prefer_auto_properties, s_preferAutoProperties, s_preferAutoProperties, Me, optionStore, codeBlockPreferencesGroupTitle)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferSystemHashCode, ServicesVSResources.Prefer_System_HashCode_in_GetHashCode, s_preferSystemHashCode, s_preferSystemHashCode, Me, optionStore, codeBlockPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferAutoProperties, ServicesVSResources.analyzer_Prefer_auto_properties, s_preferAutoProperties, s_preferAutoProperties, Me, optionStore, codeBlockPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferSystemHashCode, ServicesVSResources.Prefer_System_HashCode_in_GetHashCode, s_preferSystemHashCode, s_preferSystemHashCode, Me, optionStore, codeBlockPreferencesGroupTitle)) ' expression preferences - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferObjectInitializer, ServicesVSResources.Prefer_object_initializer, s_preferObjectInitializer, s_preferObjectInitializer, Me, optionStore, expressionPreferencesGroupTitle)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferCollectionInitializer, ServicesVSResources.Prefer_collection_initializer, s_preferCollectionInitializer, s_preferCollectionInitializer, Me, optionStore, expressionPreferencesGroupTitle)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferExplicitTupleNames, ServicesVSResources.Prefer_explicit_tuple_name, s_preferExplicitTupleName, s_preferExplicitTupleName, Me, optionStore, expressionPreferencesGroupTitle)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferInferredTupleNames, ServicesVSResources.Prefer_inferred_tuple_names, s_preferInferredTupleName, s_preferInferredTupleName, Me, optionStore, expressionPreferencesGroupTitle)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferInferredAnonymousTypeMemberNames, ServicesVSResources.Prefer_inferred_anonymous_type_member_names, s_preferInferredAnonymousTypeMemberName, s_preferInferredAnonymousTypeMemberName, Me, optionStore, expressionPreferencesGroupTitle)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferConditionalExpressionOverAssignment, ServicesVSResources.Prefer_conditional_expression_over_if_with_assignments, s_preferConditionalExpressionOverIfWithAssignments, s_preferConditionalExpressionOverIfWithAssignments, Me, optionStore, expressionPreferencesGroupTitle)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferConditionalExpressionOverReturn, ServicesVSResources.Prefer_conditional_expression_over_if_with_returns, s_preferConditionalExpressionOverIfWithReturns, s_preferConditionalExpressionOverIfWithReturns, Me, optionStore, expressionPreferencesGroupTitle)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferCompoundAssignment, ServicesVSResources.Prefer_compound_assignments, s_preferCompoundAssignments, s_preferCompoundAssignments, Me, optionStore, expressionPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferObjectInitializer, ServicesVSResources.Prefer_object_initializer, s_preferObjectInitializer, s_preferObjectInitializer, Me, optionStore, expressionPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferCollectionInitializer, ServicesVSResources.Prefer_collection_initializer, s_preferCollectionInitializer, s_preferCollectionInitializer, Me, optionStore, expressionPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferExplicitTupleNames, ServicesVSResources.Prefer_explicit_tuple_name, s_preferExplicitTupleName, s_preferExplicitTupleName, Me, optionStore, expressionPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferInferredTupleNames, ServicesVSResources.Prefer_inferred_tuple_names, s_preferInferredTupleName, s_preferInferredTupleName, Me, optionStore, expressionPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferInferredAnonymousTypeMemberNames, ServicesVSResources.Prefer_inferred_anonymous_type_member_names, s_preferInferredAnonymousTypeMemberName, s_preferInferredAnonymousTypeMemberName, Me, optionStore, expressionPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferConditionalExpressionOverAssignment, ServicesVSResources.Prefer_conditional_expression_over_if_with_assignments, s_preferConditionalExpressionOverIfWithAssignments, s_preferConditionalExpressionOverIfWithAssignments, Me, optionStore, expressionPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferConditionalExpressionOverReturn, ServicesVSResources.Prefer_conditional_expression_over_if_with_returns, s_preferConditionalExpressionOverIfWithReturns, s_preferConditionalExpressionOverIfWithReturns, Me, optionStore, expressionPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferCompoundAssignment, ServicesVSResources.Prefer_compound_assignments, s_preferCompoundAssignments, s_preferCompoundAssignments, Me, optionStore, expressionPreferencesGroupTitle)) AddUnusedValueOptions(optionStore, expressionPreferencesGroupTitle) ' nothing preferences - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferCoalesceExpression, ServicesVSResources.Prefer_coalesce_expression, s_preferCoalesceExpression, s_preferCoalesceExpression, Me, optionStore, nothingPreferencesGroupTitle)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferNullPropagation, ServicesVSResources.Prefer_null_propagation, s_preferNullPropagation, s_preferNullPropagation, Me, optionStore, nothingPreferencesGroupTitle)) - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferIsNullCheckOverReferenceEqualityMethod, BasicVSResources.Prefer_Is_Nothing_for_reference_equality_checks, s_preferIsNothingCheckOverReferenceEquals, s_preferIsNothingCheckOverReferenceEquals, Me, optionStore, nothingPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferCoalesceExpression, ServicesVSResources.Prefer_coalesce_expression, s_preferCoalesceExpression, s_preferCoalesceExpression, Me, optionStore, nothingPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferNullPropagation, ServicesVSResources.Prefer_null_propagation, s_preferNullPropagation, s_preferNullPropagation, Me, optionStore, nothingPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferIsNullCheckOverReferenceEqualityMethod, BasicVSResources.Prefer_Is_Nothing_for_reference_equality_checks, s_preferIsNothingCheckOverReferenceEquals, s_preferIsNothingCheckOverReferenceEquals, Me, optionStore, nothingPreferencesGroupTitle)) ' Field preferences - Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferReadonly, ServicesVSResources.Prefer_readonly_fields, s_preferReadonly, s_preferReadonly, Me, optionStore, fieldPreferencesGroupTitle)) + Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions2.PreferReadonly, ServicesVSResources.Prefer_readonly_fields, s_preferReadonly, s_preferReadonly, Me, optionStore, fieldPreferencesGroupTitle)) ' Parameter preferences AddParameterOptions(optionStore, parameterPreferencesGroupTitle) @@ -715,25 +715,25 @@ End Class Private Sub AddParenthesesOptions(optionStore As OptionStore) AddParenthesesOption( - LanguageNames.VisualBasic, optionStore, CodeStyleOptions.ArithmeticBinaryParentheses, + LanguageNames.VisualBasic, optionStore, CodeStyleOptions2.ArithmeticBinaryParentheses, BasicVSResources.In_arithmetic_binary_operators, {s_arithmeticBinaryAlwaysForClarity, s_arithmeticBinaryNeverIfUnnecessary}, defaultAddForClarity:=True) AddParenthesesOption( - LanguageNames.VisualBasic, optionStore, CodeStyleOptions.OtherBinaryParentheses, + LanguageNames.VisualBasic, optionStore, CodeStyleOptions2.OtherBinaryParentheses, BasicVSResources.In_other_binary_operators, {s_otherBinaryAlwaysForClarity, s_otherBinaryNeverIfUnnecessary}, defaultAddForClarity:=True) AddParenthesesOption( - LanguageNames.VisualBasic, optionStore, CodeStyleOptions.RelationalBinaryParentheses, + LanguageNames.VisualBasic, optionStore, CodeStyleOptions2.RelationalBinaryParentheses, BasicVSResources.In_relational_binary_operators, {s_relationalBinaryAlwaysForClarity, s_relationalBinaryNeverIfUnnecessary}, defaultAddForClarity:=True) AddParenthesesOption( - LanguageNames.VisualBasic, optionStore, CodeStyleOptions.OtherParentheses, + LanguageNames.VisualBasic, optionStore, CodeStyleOptions2.OtherParentheses, ServicesVSResources.In_other_operators, {s_otherParenthesesAlwaysForClarity, s_otherParenthesesNeverIfUnnecessary}, defaultAddForClarity:=False) diff --git a/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigDocumentOptionsProviderFactory.cs b/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigDocumentOptionsProviderFactory.cs index a3583e6b0aaf1..88126b9c146ef 100644 --- a/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigDocumentOptionsProviderFactory.cs +++ b/src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigDocumentOptionsProviderFactory.cs @@ -24,8 +24,8 @@ public static IDocumentOptionsProvider Create(Workspace workspace) private const string LocalRegistryPath = @"Roslyn\Internal\OnOff\Features\"; - public static readonly Option UseLegacyEditorConfigSupport = - new Option(nameof(EditorConfigDocumentOptionsProviderFactory), nameof(UseLegacyEditorConfigSupport), defaultValue: false, + public static readonly Option2 UseLegacyEditorConfigSupport = + new Option2(nameof(EditorConfigDocumentOptionsProviderFactory), nameof(UseLegacyEditorConfigSupport), defaultValue: false, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + "UseLegacySupport")); public static bool ShouldUseNativeEditorConfigSupport(Workspace workspace) diff --git a/src/Workspaces/Core/Portable/SolutionCrawler/SolutionCrawlerOptions.cs b/src/Workspaces/Core/Portable/SolutionCrawler/SolutionCrawlerOptions.cs index 30dc92fd6dd6f..0a59d988917d8 100644 --- a/src/Workspaces/Core/Portable/SolutionCrawler/SolutionCrawlerOptions.cs +++ b/src/Workspaces/Core/Portable/SolutionCrawler/SolutionCrawlerOptions.cs @@ -14,7 +14,7 @@ internal static class SolutionCrawlerOptions /// /// Option to turn configure background analysis scope. /// - public static readonly PerLanguageOption BackgroundAnalysisScopeOption = new PerLanguageOption( + public static readonly PerLanguageOption2 BackgroundAnalysisScopeOption = new PerLanguageOption2( nameof(SolutionCrawlerOptions), nameof(BackgroundAnalysisScopeOption), defaultValue: BackgroundAnalysisScope.Default, storageLocations: new RoamingProfileStorageLocation($"TextEditor.%LANGUAGE%.Specific.BackgroundAnalysisScopeOption")); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs index e97c045cc00ec..a40a87f3c8616 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeFixes/DocumentBasedFixAllProvider.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.PooledObjects; +using Roslyn.Utilities; #pragma warning disable RS0005 // Do not use generic CodeAction.Create to create CodeAction