public static BodyStyle Create(SyntaxNodeAnalysisContext context) { AnalyzerConfigOptions configOptions = context.GetConfigOptions(); var option = BodyStyleOption.None; if (ConfigOptions.TryGetValue(configOptions, ConfigOptions.BodyStyle, out string rawValue)) { if (string.Equals(rawValue, ConfigOptionValues.BodyStyle_Block, StringComparison.OrdinalIgnoreCase)) { option = BodyStyleOption.Block; } else if (string.Equals(rawValue, ConfigOptionValues.BodyStyle_Expression, StringComparison.OrdinalIgnoreCase)) { option = BodyStyleOption.Expression; } } else if (configOptions.TryGetValueAsBool(LegacyConfigOptions.ConvertExpressionBodyToBlockBody, out bool useBlockBody)) { option = (useBlockBody) ? BodyStyleOption.Block : BodyStyleOption.Expression; } bool?useBlockBodyWhenDeclarationIsMultiLine = null; if (ConfigOptions.GetValueAsBool(configOptions, ConfigOptions.UseBlockBodyWhenDeclarationSpansOverMultipleLines) == true || configOptions.IsEnabled(LegacyConfigOptions.ConvertExpressionBodyToBlockBodyWhenDeclarationIsMultiLine)) { useBlockBodyWhenDeclarationIsMultiLine = true; } bool?useBlockBodyWhenExpressionIsMultiline = null; if (ConfigOptions.GetValueAsBool(configOptions, ConfigOptions.UseBlockBodyWhenExpressionSpansOverMultipleLines) == true || configOptions.IsEnabled(LegacyConfigOptions.ConvertExpressionBodyToBlockBodyWhenExpressionIsMultiLine)) { useBlockBodyWhenExpressionIsMultiline = true; } return(new BodyStyle(option, useBlockBodyWhenDeclarationIsMultiLine, useBlockBodyWhenExpressionIsMultiline)); }
public static bool?PreferNewLineAtEndOfFile(this AnalyzerConfigOptions configOptions) { return(ConfigOptions.GetValueAsBool(configOptions, ConfigOptions.NewLineAtEndOfFile)); }
public static bool?UseVarInsteadOfImplicitObjectCreation(this SyntaxNodeAnalysisContext context) { return(ConfigOptions.GetValueAsBool(context.GetConfigOptions(), ConfigOptions.UseVarInsteadOfImplicitObjectCreation)); }