Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 private static PerLanguageOption <CodeStyleOption <ParenthesesPreference> > CreateParenthesesOption(
     string fieldName, CodeStyleOption <ParenthesesPreference> defaultValue,
     string styleName)
 {
     return(CreateOption(
                CodeStyleOptionGroups.Parentheses, fieldName, defaultValue,
                storageLocations: new OptionStorageLocation[] {
         new EditorConfigStorageLocation <CodeStyleOption <ParenthesesPreference> >(
             styleName,
             s => ParseParenthesesPreference(s, defaultValue),
             v => GetParenthesesPreferenceEditorConfigString(v)),
         new RoamingProfileStorageLocation($"TextEditor.%LANGUAGE%.Specific.{fieldName}Preference")
     }));
 }
Esempio n. 4
0
 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")
 });
Esempio n. 5
0
        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()}");
        }