示例#1
0
        /// <summary>Compares two nodes and returns a value indicating whether one is less than, equal to, or greater than the other according to StyleCop.</summary>
        /// <returns>A signed integer that indicates if the node should be before the other according to StyleCop.</returns>
        /// <param name="x">The first node to compare.</param>
        /// <param name="y">The second node to compare.</param>
        public static int Compare(ConstructorDeclarationSyntax x, ConstructorDeclarationSyntax y)
        {
            if (ReferenceEquals(x, y))
            {
                return(0);
            }

            if (x == null)
            {
                return(-1);
            }

            if (y == null)
            {
                return(1);
            }

            var compare = MemberDeclarationComparer.CompareScope(x.Modifiers, y.Modifiers);

            if (compare != 0)
            {
                return(compare);
            }

            compare = MemberDeclarationComparer.CompareAccessability(x.Modifiers, y.Modifiers, Accessibility.Private);
            if (compare != 0)
            {
                return(compare);
            }

            return(MemberDeclarationComparer.CompareSpanStart(x.SpanStart, y.SpanStart));
        }
示例#2
0
        /// <summary>Compares two nodes and returns a value indicating whether one is less than, equal to, or greater than the other according to StyleCop.</summary>
        /// <returns>A signed integer that indicates if the node should be before the other according to StyleCop.</returns>
        /// <param name="x">The first node to compare.</param>
        /// <param name="y">The second node to compare.</param>
        public static int Compare(FieldDeclarationSyntax x, FieldDeclarationSyntax y)
        {
            if (ReferenceEquals(x, y))
            {
                return(0);
            }

            if (x == null)
            {
                return(-1);
            }

            if (y == null)
            {
                return(1);
            }

            if (IsInitializedWith(x, y))
            {
                return(1);
            }

            if (IsInitializedWith(y, x))
            {
                return(-1);
            }

            var compare = MemberDeclarationComparer.CompareAccessability(x.Modifiers, y.Modifiers, Accessibility.Private);

            if (compare != 0)
            {
                return(compare);
            }

            compare = MemberDeclarationComparer.CompareScope(x.Modifiers, y.Modifiers);
            if (compare != 0)
            {
                return(compare);
            }

            compare = CompareReadOnly(x, y);
            if (compare != 0)
            {
                return(compare);
            }

            compare = CompareBackingProperty(x, y);
            if (compare != 0)
            {
                return(compare);
            }

            return(MemberDeclarationComparer.CompareSpanStart(x.SpanStart, y.SpanStart));
        }