// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections; using System.Collections.Generic; using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.Options; namespace Microsoft.CodeAnalysis.CSharp.CodeStyle { internal static class CSharpCodeStyleOptions { // TODO: get sign off on public api changes. public static readonly Option UseVarWhenDeclaringLocals = new Option( nameof(CodeStyleOptions), nameof(UseVarWhenDeclaringLocals), defaultValue: true, storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseVarWhenDeclaringLocals")); public static readonly Option> UseImplicitTypeForIntrinsicTypes = new Option>( nameof(CodeStyleOptions), nameof(UseImplicitTypeForIntrinsicTypes), defaultValue: CodeStyleOption.Default, storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseImplicitTypeForIntrinsicTypes")); public static readonly Option> UseImplicitTypeWhereApparent = new Option>( nameof(CodeStyleOptions), nameof(UseImplicitTypeWhereApparent), defaultValue: CodeStyleOption.Default, storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseImplicitTypeWhereApparent")); public static readonly Option> UseImplicitTypeWherePossible = new Option>( nameof(CodeStyleOptions), nameof(UseImplicitTypeWherePossible), defaultValue: CodeStyleOption.Default, storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.UseImplicitTypeWherePossible")); public static readonly Option> PreferConditionalDelegateCall = new Option>(nameof(CodeStyleOptions), nameof(PreferConditionalDelegateCall), defaultValue: CodeStyleOptions.TrueWithSuggestionEnforcement, storageLocations: new RoamingProfileStorageLocation("TextEditor.CSharp.Specific.PreferConditionalDelegateCall")); public static readonly Option> PreferPatternMatchingOverAsWithNullCheck = new Option>( nameof(CodeStyleOptions), nameof(PreferPatternMatchingOverAsWithNullCheck), defaultValue: CodeStyleOptions.TrueWithSuggestionEnforcement, storageLocations: new RoamingProfileStorageLocation($"TextEditor.CSharp.Specific.{nameof(PreferPatternMatchingOverAsWithNullCheck)}")); public static readonly Option> PreferPatternMatchingOverIsWithCastCheck = new Option>( nameof(CodeStyleOptions), nameof(PreferPatternMatchingOverIsWithCastCheck), defaultValue: CodeStyleOptions.TrueWithSuggestionEnforcement, storageLocations: new RoamingProfileStorageLocation($"TextEditor.CSharp.Specific.{nameof(PreferPatternMatchingOverIsWithCastCheck)}")); public static readonly Option> PreferExpressionBodiedConstructors = new Option>( nameof(CodeStyleOptions), nameof(PreferExpressionBodiedConstructors), defaultValue: CodeStyleOptions.FalseWithNoneEnforcement, storageLocations: new RoamingProfileStorageLocation($"TextEditor.CSharp.Specific.{nameof(PreferExpressionBodiedConstructors)}")); public static readonly Option> PreferExpressionBodiedMethods = new Option>( nameof(CodeStyleOptions), nameof(PreferExpressionBodiedMethods), defaultValue: CodeStyleOptions.FalseWithNoneEnforcement, storageLocations: new RoamingProfileStorageLocation($"TextEditor.CSharp.Specific.{nameof(PreferExpressionBodiedMethods)}")); public static readonly Option> PreferExpressionBodiedOperators = new Option>( nameof(CodeStyleOptions), nameof(PreferExpressionBodiedOperators), defaultValue: CodeStyleOptions.FalseWithNoneEnforcement, storageLocations: new RoamingProfileStorageLocation($"TextEditor.CSharp.Specific.{nameof(PreferExpressionBodiedOperators)}")); public static readonly Option> PreferExpressionBodiedProperties = new Option>( nameof(CodeStyleOptions), nameof(PreferExpressionBodiedProperties), defaultValue: CodeStyleOptions.TrueWithNoneEnforcement, storageLocations: new RoamingProfileStorageLocation($"TextEditor.CSharp.Specific.{nameof(PreferExpressionBodiedProperties)}")); public static readonly Option> PreferExpressionBodiedIndexers = new Option>( nameof(CodeStyleOptions), nameof(PreferExpressionBodiedIndexers), defaultValue: CodeStyleOptions.TrueWithNoneEnforcement, storageLocations: new RoamingProfileStorageLocation($"TextEditor.CSharp.Specific.{nameof(PreferExpressionBodiedIndexers)}")); public static readonly Option> PreferExpressionBodiedAccessors = new Option>( nameof(CodeStyleOptions), nameof(PreferExpressionBodiedAccessors), defaultValue: CodeStyleOptions.TrueWithNoneEnforcement, storageLocations: new RoamingProfileStorageLocation($"TextEditor.CSharp.Specific.{nameof(PreferExpressionBodiedAccessors)}")); public static IEnumerable>> GetCodeStyleOptions() { yield return UseImplicitTypeForIntrinsicTypes; yield return UseImplicitTypeWhereApparent; yield return UseImplicitTypeWherePossible; yield return PreferConditionalDelegateCall; yield return PreferPatternMatchingOverAsWithNullCheck; yield return PreferPatternMatchingOverIsWithCastCheck; yield return PreferExpressionBodiedConstructors; yield return PreferExpressionBodiedMethods; yield return PreferExpressionBodiedOperators; yield return PreferExpressionBodiedProperties; yield return PreferExpressionBodiedIndexers; yield return PreferExpressionBodiedAccessors; } } }