/// <summary>
        /// Fires low-level violation.
        /// </summary>
        private void AddViolation(
            CsElement element,
            int?lineNumber,
            string friendlyName,
            string currentName,
            string example)
        {
            example = example.TrimExample();

            if (lineNumber.HasValue)
            {
                m_parent.AddViolation(
                    element,
                    lineNumber.Value,
                    Rules.AdvancedNamingRules,
                    friendlyName,
                    currentName,
                    example);
            }
            else
            {
                m_parent.AddViolation(
                    element,
                    Rules.AdvancedNamingRules,
                    friendlyName,
                    currentName,
                    example);
            }
        }
Пример #2
0
        /// <summary>
        /// Checks if specified element violates size limit.
        /// </summary>
        private void CheckSizeLimit(CsElement element, Rules rule, NumericValue limit)
        {
            int size = CodeHelper.GetElementSizeByDeclaration(element);

            if (size > limit.Value)
            {
                m_parent.AddViolation(
                    element,
                    rule,
                    limit.Value,
                    size);
            }
        }
Пример #3
0
        /// <summary>
        /// Handles SA1502 violation.
        /// </summary>
        private void Handle1502(ViolationEventArgs e)
        {
            CsElement element = (CsElement)e.Element;

            if (ReadSetting(e, AllowConstructorsFor1502))
            {
                if (element.ElementType == ElementType.Constructor)
                {
                    return;
                }
            }

            m_parent.AddViolation(
                element,
                e.LineNumber,
                Rules.ElementMustNotBeOnSingleLine,
                element.FriendlyTypeText);
        }