コード例 #1
0
ファイル: CodeStyleHelpers.cs プロジェクト: sidkcr/roslyn
        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);
        }
コード例 #2
0
ファイル: CodeStyleOptions.cs プロジェクト: sidkcr/roslyn
 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")
     }));
 }
コード例 #3
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);
        }
コード例 #4
0
ファイル: CodeStyleOptions.cs プロジェクト: xyz37/roslyn
 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")
     }));
 }
コード例 #5
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")
 });
コード例 #6
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()}");
        }
コード例 #7
0
 public bool Equals(CodeStyleOption <T> other)
 {
     return(EqualityComparer <T> .Default.Equals(Value, other.Value) &&
            Notification == other.Notification);
 }