public static bool ShouldReportUnusedParameters(
            ISymbol symbol,
            UnusedParametersPreference unusedParametersPreference,
            ReportDiagnostic unusedParametersSeverity)
        {
            if (unusedParametersSeverity == ReportDiagnostic.Suppress)
            {
                return(false);
            }

            if (unusedParametersPreference == UnusedParametersPreference.NonPublicMethods)
            {
                return(!symbol.HasPublicResultantVisibility());
            }

            return(true);
        }
            public Options(
                UnusedValuePreference unusedValueExpressionStatementPreference,
                ReportDiagnostic unusedValueExpressionStatementSeverity,
                UnusedValuePreference unusedValueAssignmentPreference,
                ReportDiagnostic unusedValueAssignmentSeverity,
                UnusedParametersPreference unusedParametersPreference,
                ReportDiagnostic unusedParametersSeverity)
            {
                Debug.Assert(unusedValueExpressionStatementSeverity != ReportDiagnostic.Suppress ||
                             unusedValueAssignmentSeverity != ReportDiagnostic.Suppress ||
                             unusedParametersSeverity != ReportDiagnostic.Suppress);

                UnusedValueExpressionStatementPreference = unusedValueExpressionStatementPreference;
                UnusedValueExpressionStatementSeverity   = unusedValueExpressionStatementSeverity;
                UnusedValueAssignmentPreference          = unusedValueAssignmentPreference;
                UnusedValueAssignmentSeverity            = unusedValueAssignmentSeverity;
                _unusedParametersPreference = unusedParametersPreference;
                _unusedParametersSeverity   = unusedParametersSeverity;
            }
        public static bool ShouldReportUnusedParameters(
            ISymbol symbol,
            UnusedParametersPreference unusedParametersPreference,
            ReportDiagnostic unusedParametersSeverity)
        {
            if (unusedParametersSeverity == ReportDiagnostic.Suppress)
            {
                return(false);
            }

            switch (unusedParametersPreference)
            {
            case UnusedParametersPreference.AllMethods:
                return(true);

            case UnusedParametersPreference.NonPublicMethods:
                return(!symbol.HasPublicResultantVisibility());

            default:
                throw ExceptionUtilities.Unreachable;
            }
        }
Exemple #4
0
        private static string GetUnusedParametersPreferenceEditorConfigString(CodeStyleOption <UnusedParametersPreference> option, UnusedParametersPreference defaultPreference)
        {
            Debug.Assert(s_unusedParametersPreferenceMap.ContainsValue(option.Value));
            var value = s_unusedParametersPreferenceMap.GetKeyOrDefault(option.Value) ?? s_unusedParametersPreferenceMap.GetKeyOrDefault(defaultPreference);

            return(option.Notification == null ? value : $"{value}:{option.Notification.ToEditorConfigString()}");
        }