예제 #1
0
        public static bool TryParseBoolEditorConfigCodeStyleOption(string arg, out CodeStyleOption2 <bool> option)
        {
            if (TryGetCodeStyleValueAndOptionalNotification(
                    arg, out var value, out var notificationOpt))
            {
                // First value has to be true or false.  Anything else is unsupported.
                if (bool.TryParse(value, out var isEnabled))
                {
                    // We allow 'false' to be provided without a notification option.  However,
                    // 'true' must always be provided with a notification option.
                    if (isEnabled == false)
                    {
                        notificationOpt ??= NotificationOption2.Silent;
                        option = new CodeStyleOption2 <bool>(false, notificationOpt);
                        return(true);
                    }
                    else if (notificationOpt != null)
                    {
                        option = new CodeStyleOption2 <bool>(true, notificationOpt);
                        return(true);
                    }
                }
            }

            option = CodeStyleOption2 <bool> .Default;
            return(false);
        }
예제 #2
0
        public static bool TryParseBoolEditorConfigCodeStyleOption(
            string arg,
            CodeStyleOption2 <bool> defaultValue,
            out CodeStyleOption2 <bool> option
            )
        {
            if (
                TryGetCodeStyleValueAndOptionalNotification(
                    arg,
                    defaultValue.Notification,
                    out var value,
                    out var notification
                    )
                )
            {
                // First value has to be true or false.  Anything else is unsupported.
                if (bool.TryParse(value, out var isEnabled))
                {
                    option = new CodeStyleOption2 <bool>(isEnabled, notification);
                    return(true);
                }
            }

            option = defaultValue;
            return(false);
        }
예제 #3
0
        /// <summary>
        /// Helper to get the true ReportDiagnostic severity for a given option.  Importantly, this
        /// handle ReportDiagnostic.Default and will map that back to the appropriate value in that
        /// case.
        /// </summary>
        protected static ReportDiagnostic GetOptionSeverity(CodeStyleOption2 <TOptionKind> optionValue)
        {
            var severity = optionValue.Notification.Severity;

            return(severity == ReportDiagnostic.Default
                ? severity.WithDefaultSeverity(DiagnosticSeverity.Hidden)
                : severity);
        }
예제 #4
0
        public static bool TryParseStringEditorConfigCodeStyleOption(string arg, CodeStyleOption2 <string> defaultValue, [NotNullWhen(true)] out CodeStyleOption2 <string>?option)
        {
            if (TryGetCodeStyleValueAndOptionalNotification(
                    arg, defaultValue.Notification, out var value, out var notification))
            {
                option = new CodeStyleOption2 <string>(value, notification);
                return(true);
            }

            option = null;
            return(false);
        }
예제 #5
0
        public static bool TryParseStringEditorConfigCodeStyleOption(string arg, out CodeStyleOption2 <string> option)
        {
            if (TryGetCodeStyleValueAndOptionalNotification(
                    arg, out var value, out var notificationOpt))
            {
                option = new CodeStyleOption2 <string>(value, notificationOpt ?? NotificationOption2.Silent);
                return(true);
            }

            option = null;
            return(false);
        }
예제 #6
0
 private static PerLanguageOption2 <CodeStyleOption2 <bool> > CreateOption(
     OptionGroup group,
     string name,
     CodeStyleOption2 <bool> defaultValue,
     string editorconfigKeyName,
     string roamingProfileStorageKeyName
     ) =>
 CreateOption(
     group,
     name,
     defaultValue,
     EditorConfigStorageLocation.ForBoolCodeStyleOption(
         editorconfigKeyName,
         defaultValue
         ),
     new RoamingProfileStorageLocation(roamingProfileStorageKeyName)
     );