public static bool TryParseStringEditorConfigCodeStyleOption(string arg, out CodeStyleOption <string> option) { if (TryGetCodeStyleValueAndOptionalNotification( arg, out string value, out NotificationOption notificationOpt)) { option = new CodeStyleOption <string>(value, notificationOpt ?? NotificationOption.Silent); return(true); } option = null; return(false); }
private static PerLanguageOption <CodeStyleOption <ParenthesesPreference> > CreateParenthesesOption( string fieldName, CodeStyleOption <ParenthesesPreference> defaultValue, string styleName) { return(new PerLanguageOption <CodeStyleOption <ParenthesesPreference> >( nameof(CodeStyleOptions), fieldName, defaultValue, storageLocations: new OptionStorageLocation[] { new EditorConfigStorageLocation <CodeStyleOption <ParenthesesPreference> >( styleName, s => ParseParenthesesPreference(s, defaultValue)), new RoamingProfileStorageLocation($"TextEditor.%LANGUAGE%.Specific.{fieldName}Preference") })); }
private static Optional <CodeStyleOption <UnusedValuePreference> > ParseUnusedExpressionAssignmentPreference( string optionString, CodeStyleOption <UnusedValuePreference> defaultCodeStyleOption) { if (TryGetCodeStyleValueAndOptionalNotification(optionString, out var value, out var notificationOpt)) { return(new CodeStyleOption <UnusedValuePreference>( s_unusedExpressionAssignmentPreferenceMap.GetValueOrDefault(value), notificationOpt ?? defaultCodeStyleOption.Notification)); } return(s_preferNoneUnusedValuePreference); }
private static PerLanguageOption <CodeStyleOption <ParenthesesPreference> > CreateParenthesesOption( string fieldName, CodeStyleOption <ParenthesesPreference> defaultValue, string styleName, bool allowIgnore, bool allowAlwaysForClarity) { Debug.Assert(allowIgnore != allowAlwaysForClarity); return(new PerLanguageOption <CodeStyleOption <ParenthesesPreference> >( nameof(CodeStyleOptions), fieldName, defaultValue, storageLocations: new OptionStorageLocation[] { new EditorConfigStorageLocation <CodeStyleOption <ParenthesesPreference> >( styleName, s => ParseParenthesesPreference(s, defaultValue, allowIgnore, allowAlwaysForClarity)), new RoamingProfileStorageLocation($"TextEditor.%LANGUAGE%.Specific.{fieldName}Preference") })); }
public static Option <CodeStyleOption <UnusedValuePreference> > CreateUnusedExpressionAssignmentOption( OptionGroup group, string feature, string name, string editorConfigName, CodeStyleOption <UnusedValuePreference> defaultValue, ImmutableArray <IOption> .Builder optionsBuilder) => CreateOption( group, feature, name, defaultValue, optionsBuilder, storageLocations: new OptionStorageLocation[] { new EditorConfigStorageLocation <CodeStyleOption <UnusedValuePreference> >( editorConfigName, s => ParseUnusedExpressionAssignmentPreference(s, defaultValue), o => GetUnusedExpressionAssignmentPreferenceEditorConfigString(o, defaultValue.Value)), new RoamingProfileStorageLocation($"TextEditor.%LANGUAGE%.Specific.{name}Preference") });
private static string GetUnusedExpressionAssignmentPreferenceEditorConfigString(CodeStyleOption <UnusedValuePreference> option, UnusedValuePreference defaultPreference) { Debug.Assert(s_unusedExpressionAssignmentPreferenceMap.ContainsValue(option.Value)); var value = s_unusedExpressionAssignmentPreferenceMap.GetKeyOrDefault(option.Value) ?? s_unusedExpressionAssignmentPreferenceMap.GetKeyOrDefault(defaultPreference); return(option.Notification == null ? value : $"{value}:{option.Notification.ToEditorConfigString()}"); }
public bool Equals(CodeStyleOption <T> other) { return(EqualityComparer <T> .Default.Equals(Value, other.Value) && Notification == other.Notification); }