151 references to CodeStyleOption2
Microsoft.CodeAnalysis.CSharp.Features (1)
Formatting\CSharpUseProgramMainNewDocumentFormattingProvider.cs (1)
29
var
option = ((CSharpSyntaxFormattingOptions)options.FormattingOptions).PreferTopLevelStatements;
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (1)
src\Analyzers\CSharp\Tests\UseExpressionBody\UseExpressionBodyForMethodsAnalyzerTests.cs (1)
50
var
option = CSharpCodeStyleOptions.ParseExpressionBodyPreference("true", CSharpCodeStyleOptions.NeverWithSilentEnforcement);
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CodeStyle\PreferBracesPreference.cs (2)
20
/// <see cref="
CodeStyleOption2
{T}.FromXElement(XElement)"/>. Prior to the use of this enum, the serialized value
37
/// <see cref="
CodeStyleOption2
{T}.FromXElement(XElement)"/>. Prior to the use of this enum, the serialized value
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (2)
CodeStyle\CSharpEditorConfigCodeStyleParserTests.cs (2)
59
var
codeStyleOption = CSharpCodeStyleOptions.ParseExpressionBodyPreference(optionString, defaultValue);
75
var
codeStyleOption = CSharpCodeStyleOptions.ParseUsingDirectivesPlacement(optionString, defaultValue);
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
EditorConfigSettings\Data\CodeStyleSettingsTest.cs (2)
81
var
defaultCodeStyle = CodeStyleOption2<bool>.Default.WithValue(defaultValue);
93
var
defaultCodeStyle = CodeStyleOption2<T>.Default.WithValue(defaultValue);
Microsoft.CodeAnalysis.Workspaces (140)
CodeStyle\CodeStyleOption.cs (4)
25
/// <inheritdoc cref="
CodeStyleOption2
{T}"/>
30
internal CodeStyleOption(
CodeStyleOption2
<T> codeStyleOptionImpl)
59
internal
CodeStyleOption2
<T> UnderlyingOption { get; }
64
=> new(
CodeStyleOption2
<T>.FromXElement(element));
CodeStyle\CodeStyleOption2_operators.cs (2)
14
public static explicit operator CodeStyleOption<T>?(
CodeStyleOption2
<T>? option)
25
public static explicit operator
CodeStyleOption2
<T>?(CodeStyleOption<T>? option)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\AddImport\AddImportPlacementOptions.cs (2)
13
public static readonly
CodeStyleOption2
<AddImportPlacement> s_outsideNamespacePlacementWithSilentEnforcement =
23
public
CodeStyleOption2
<AddImportPlacement> UsingDirectivePlacement { get; init; } = s_outsideNamespacePlacementWithSilentEnforcement;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CodeStyleHelpers.cs (23)
16
public static bool TryParseStringEditorConfigCodeStyleOption(string arg,
CodeStyleOption2
<string> defaultValue, [NotNullWhen(true)] out
CodeStyleOption2
<string>? option)
29
public static bool TryParseBoolEditorConfigCodeStyleOption(string arg,
CodeStyleOption2
<bool> defaultValue, out
CodeStyleOption2
<bool> option)
117
public static Option2<
CodeStyleOption2
<T>> CreateEditorConfigOption<T>(
120
CodeStyleOption2
<T> defaultValue,
123
Func<
CodeStyleOption2
<T>, EditorConfigValueSerializer<
CodeStyleOption2
<T>>>? serializerFactory = null)
125
var option = new Option2<
CodeStyleOption2
<T>>(name, defaultValue, group, languageName, isEditorConfigOption: true, serializer: (serializerFactory ?? EditorConfigValueSerializer.CodeStyle).Invoke(defaultValue));
142
public static PerLanguageOption2<
CodeStyleOption2
<T>> CreatePerLanguageEditorConfigOption<T>(
145
CodeStyleOption2
<T> defaultValue,
147
Func<
CodeStyleOption2
<T>, EditorConfigValueSerializer<
CodeStyleOption2
<T>>>? serializerFactory = null)
149
var option = new PerLanguageOption2<
CodeStyleOption2
<T>>(name, defaultValue, group, isEditorConfigOption: true, serializer: (serializerFactory ?? EditorConfigValueSerializer.CodeStyle).Invoke(defaultValue));
154
private static readonly
CodeStyleOption2
<UnusedValuePreference> s_preferNoneUnusedValuePreference =
164
internal static EditorConfigValueSerializer<
CodeStyleOption2
<UnusedValuePreference>> GetUnusedValuePreferenceSerializer(
CodeStyleOption2
<UnusedValuePreference> defaultValue)
168
private static Optional<
CodeStyleOption2
<UnusedValuePreference>> ParseUnusedExpressionAssignmentPreference(
170
CodeStyleOption2
<UnusedValuePreference> defaultCodeStyleOption)
182
private static string GetUnusedExpressionAssignmentPreferenceEditorConfigString(
CodeStyleOption2
<UnusedValuePreference> option,
CodeStyleOption2
<UnusedValuePreference> defaultValue)
189
internal static string GetEditorConfigStringNotificationPart<T>(
CodeStyleOption2
<T> option,
CodeStyleOption2
<T> defaultValue)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CodeStyleOption2`1.cs (12)
41
public static readonly
CodeStyleOption2
<bool> TrueWithSilentEnforcement = new(value: true, notification: NotificationOption2.Silent);
42
public static readonly
CodeStyleOption2
<bool> FalseWithSilentEnforcement = new(value: false, notification: NotificationOption2.Silent);
43
public static readonly
CodeStyleOption2
<bool> TrueWithSuggestionEnforcement = new(value: true, notification: NotificationOption2.Suggestion);
44
public static readonly
CodeStyleOption2
<bool> FalseWithSuggestionEnforcement = new(value: false, notification: NotificationOption2.Suggestion);
49
public static
CodeStyleOption2
<bool> GetCodeStyle(bool value, NotificationOption2 notification)
75
internal sealed partial class CodeStyleOption2<T>(T value, NotificationOption2 notification) : ICodeStyleOption2, IEquatable<
CodeStyleOption2
<T>?>
77
public static readonly
CodeStyleOption2
<T> Default = new(default!, NotificationOption2.Silent);
97
public
CodeStyleOption2
<T> WithValue(T value)
107
return (
CodeStyleOption2
<T>)(object)CodeStyleOption2.GetCodeStyle(boolValue, Notification);
168
public static
CodeStyleOption2
<T> FromXElement(XElement element)
237
public bool Equals(
CodeStyleOption2
<T>? other)
245
=> obj is
CodeStyleOption2
<T> option &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CodeStyleOptions2.cs (45)
22
private static PerLanguageOption2<
CodeStyleOption2
<T>> CreatePerLanguageOption<T>(
23
OptionGroup group, string name,
CodeStyleOption2
<T> defaultValue, Func<
CodeStyleOption2
<T>, EditorConfigValueSerializer<
CodeStyleOption2
<T>>>? serializerFactory = null)
26
private static Option2<
CodeStyleOption2
<T>> CreateOption<T>(
27
OptionGroup group, string name,
CodeStyleOption2
<T> defaultValue, Func<
CodeStyleOption2
<T>, EditorConfigValueSerializer<
CodeStyleOption2
<T>>>? serializerFactory = null)
34
private static PerLanguageOption2<
CodeStyleOption2
<bool>> CreateQualifyAccessOption(string name)
40
public static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> QualifyFieldAccess = CreateQualifyAccessOption(
47
public static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> QualifyPropertyAccess = CreateQualifyAccessOption(
54
public static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> QualifyMethodAccess = CreateQualifyAccessOption(
61
public static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> QualifyEventAccess = CreateQualifyAccessOption(
68
public static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferIntrinsicPredefinedTypeKeywordInDeclaration = CreatePerLanguageOption(
77
public static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferIntrinsicPredefinedTypeKeywordInMemberAccess = CreatePerLanguageOption(
83
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferObjectInitializer = CreatePerLanguageOption(
88
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferCollectionInitializer = CreatePerLanguageOption(
93
internal static readonly PerLanguageOption2<
CodeStyleOption2
<CollectionExpressionPreference>> PreferCollectionExpression = CreatePerLanguageOption(
101
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferSimplifiedBooleanExpressions = CreatePerLanguageOption(
114
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferCoalesceExpression = CreatePerLanguageOption(
119
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferNullPropagation = CreatePerLanguageOption(
124
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferExplicitTupleNames = CreatePerLanguageOption(
129
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferAutoProperties = CreatePerLanguageOption(
134
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferInferredTupleNames = CreatePerLanguageOption(
139
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferInferredAnonymousTypeMemberNames = CreatePerLanguageOption(
144
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferIsNullCheckOverReferenceEqualityMethod = CreatePerLanguageOption(
149
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferConditionalExpressionOverAssignment = CreatePerLanguageOption(
154
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferConditionalExpressionOverReturn = CreatePerLanguageOption(
159
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferCompoundAssignment = CreatePerLanguageOption(
164
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferSimplifiedInterpolation = CreatePerLanguageOption(
176
internal static readonly PerLanguageOption2<
CodeStyleOption2
<UnusedParametersPreference>> UnusedParameters = CreatePerLanguageOption(
206
internal static readonly PerLanguageOption2<
CodeStyleOption2
<AccessibilityModifiersRequired>> AccessibilityModifiersRequired = CreatePerLanguageOption(
226
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferReadonly = CreatePerLanguageOption(
250
private static PerLanguageOption2<
CodeStyleOption2
<ParenthesesPreference>> CreateParenthesesOption(
CodeStyleOption2
<ParenthesesPreference> defaultValue, string name)
273
private static readonly
CodeStyleOption2
<ParenthesesPreference> s_alwaysForClarityPreference =
276
internal static readonly PerLanguageOption2<
CodeStyleOption2
<ParenthesesPreference>> ArithmeticBinaryParentheses =
281
internal static readonly PerLanguageOption2<
CodeStyleOption2
<ParenthesesPreference>> OtherBinaryParentheses =
286
internal static readonly PerLanguageOption2<
CodeStyleOption2
<ParenthesesPreference>> RelationalBinaryParentheses =
291
internal static readonly PerLanguageOption2<
CodeStyleOption2
<ParenthesesPreference>> OtherParentheses =
303
internal static readonly Option2<
CodeStyleOption2
<ForEachExplicitCastInSourcePreference>> ForEachExplicitCastInSource = CreateOption(
327
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferSystemHashCode = CreatePerLanguageOption(
332
public static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> PreferNamespaceAndFolderMatchStructure = CreatePerLanguageOption(
337
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> AllowMultipleBlankLines = CreatePerLanguageOption(
342
internal static readonly PerLanguageOption2<
CodeStyleOption2
<bool>> AllowStatementImmediatelyAfterBlock = CreatePerLanguageOption(
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\CollectionExpressionPreference.cs (4)
27
CodeStyleOption2
<CollectionExpressionPreference> value,
28
CodeStyleOption2
<CollectionExpressionPreference> defaultValue)
40
public static Optional<
CodeStyleOption2
<CollectionExpressionPreference>> Parse(
41
string optionString,
CodeStyleOption2
<CollectionExpressionPreference> defaultValue)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CodeStyle\VisualBasic\VisualBasicCodeStyleOptions.cs (9)
18
private static Option2<
CodeStyleOption2
<T>> CreateOption<T>(
21
CodeStyleOption2
<T> defaultValue,
22
Func<
CodeStyleOption2
<T>, EditorConfigValueSerializer<
CodeStyleOption2
<T>>>? serializerFactory = null)
27
public static readonly Option2<
CodeStyleOption2
<string>> PreferredModifierOrder = CreateOption(
35
public static readonly Option2<
CodeStyleOption2
<bool>> PreferIsNotExpression = CreateOption(
40
public static readonly Option2<
CodeStyleOption2
<bool>> PreferSimplifiedObjectCreation = CreateOption(
45
public static readonly Option2<
CodeStyleOption2
<UnusedValuePreference>> UnusedValueExpressionStatement = CreateOption(
51
public static readonly Option2<
CodeStyleOption2
<UnusedValuePreference>> UnusedValueAssignment = CreateOption(
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalyzerConfigOptionsExtensions.cs (2)
19
=> TryGetEditorConfigOption<
CodeStyleOption2
<T>>(analyzerConfigOptions, option, out
var
style) ? style!.Value : defaultValue;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\EditorConfigValueSerializer.cs (14)
80
public static EditorConfigValueSerializer<
CodeStyleOption2
<T>> CodeStyle<T>(
CodeStyleOption2
<T> defaultValue)
83
return (EditorConfigValueSerializer<
CodeStyleOption2
<T>>)(object)CodeStyle((
CodeStyleOption2
<bool>)(object)defaultValue);
86
return (EditorConfigValueSerializer<
CodeStyleOption2
<T>>)(object)CodeStyle((
CodeStyleOption2
<string>)(object)defaultValue);
91
public static EditorConfigValueSerializer<
CodeStyleOption2
<bool>> CodeStyle(
CodeStyleOption2
<bool> defaultValue)
92
=> new(parseValue: str => CodeStyleHelpers.TryParseBoolEditorConfigCodeStyleOption(str, defaultValue, out
var
result) ? result : new Optional<
CodeStyleOption2
<bool>>(),
95
public static EditorConfigValueSerializer<
CodeStyleOption2
<string>> CodeStyle(
CodeStyleOption2
<string> defaultValue)
96
=> new(parseValue: str => CodeStyleHelpers.TryParseStringEditorConfigCodeStyleOption(str, defaultValue, out
var
result) ? result : new Optional<
CodeStyleOption2
<string>>(),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\IOptionReader.cs (6)
44
public static T GetOptionValue<T>(this IOptionsReader options, Option2<
CodeStyleOption2
<T>> option)
47
public static T GetOptionValue<T>(this IOptionsReader options, Option2<
CodeStyleOption2
<T>> option, T defaultValue)
48
=> options.TryGetOption<
CodeStyleOption2
<T>>(new OptionKey2(option), out var style) ? style!.Value : defaultValue;
50
public static T GetOptionValue<T>(this IOptionsReader options, PerLanguageOption2<
CodeStyleOption2
<T>> option, string language)
53
public static T GetOptionValue<T>(this IOptionsReader options, PerLanguageOption2<
CodeStyleOption2
<T>> option, string language, T defaultValue)
54
=> options.TryGetOption<
CodeStyleOption2
<T>>(new OptionKey2(option, language), out var style) ? style!.Value : defaultValue;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Options\PublicOptionFactory.cs (6)
80
public static Option2<
CodeStyleOption2
<T>> WithPublicOption<T>(this Option2<
CodeStyleOption2
<T>> option, string feature, string name)
86
public static PerLanguageOption2<
CodeStyleOption2
<T>> WithPublicOption<T>(this PerLanguageOption2<
CodeStyleOption2
<T>> option, string feature, string name)
101
public static Option<CodeStyleOption<T>> ToPublicOption<T>(this Option2<
CodeStyleOption2
<T>> option)
107
public static PerLanguageOption<CodeStyleOption<T>> ToPublicOption<T>(this PerLanguageOption2<
CodeStyleOption2
<T>> option)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Simplification\SimplifierOptions.cs (8)
14
public static readonly
CodeStyleOption2
<bool> DefaultQualifyAccess = CodeStyleOption2.FalseWithSilentEnforcement;
21
[DataMember] public
CodeStyleOption2
<bool> QualifyFieldAccess { get; init; } = CodeStyleOption2.FalseWithSilentEnforcement;
22
[DataMember] public
CodeStyleOption2
<bool> QualifyPropertyAccess { get; init; } = CodeStyleOption2.FalseWithSilentEnforcement;
23
[DataMember] public
CodeStyleOption2
<bool> QualifyMethodAccess { get; init; } = CodeStyleOption2.FalseWithSilentEnforcement;
24
[DataMember] public
CodeStyleOption2
<bool> QualifyEventAccess { get; init; } = CodeStyleOption2.FalseWithSilentEnforcement;
25
[DataMember] public
CodeStyleOption2
<bool> PreferPredefinedTypeKeywordInMemberAccess { get; init; } = CodeStyleOption2.TrueWithSilentEnforcement;
26
[DataMember] public
CodeStyleOption2
<bool> PreferPredefinedTypeKeywordInDeclaration { get; init; } = CodeStyleOption2.TrueWithSilentEnforcement;
42
public bool TryGetQualifyMemberAccessOption(SymbolKind symbolKind, [NotNullWhen(true)] out
CodeStyleOption2
<bool>? option)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\AbstractAddImportsService.cs (1)
44
public abstract
CodeStyleOption2
<AddImportPlacement> GetUsingDirectivePlacementCodeStyleOption(IOptionsReader configOptions);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Simplification\SimplificationHelpers.cs (1)
123
return options.TryGetQualifyMemberAccessOption(symbol.Kind, out
var
symbolOptions) && !symbolOptions.Value;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Simplification\Simplifiers\AbstractMemberAccessExpressionSimplifier.cs (1)
58
if (!simplifierOptions.TryGetQualifyMemberAccessOption(symbolInfo.Symbol.Kind, out
var
optionValue))
Microsoft.CodeAnalysis.Workspaces.UnitTests (3)
CodeStyle\EditorConfigCodeStyleParserTests.cs (1)
39
CodeStyleHelpers.TryParseBoolEditorConfigCodeStyleOption(args, defaultValue: CodeStyleOption2<bool>.Default, out
var
result);
Options\CodeStyleOptionTests.cs (2)
83
var
deserialized = CodeStyleOption2<ExpressionBodyPreference>.FromXElement(serialized);
102
var
deserialized = CodeStyleOption2<bool>.FromXElement(serialized);