예제 #1
0
        public static bool Equals(INamedTypeSymbol x, INamedTypeSymbol y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }

            if (x == null ||
                y == null)
            {
                return(false);
            }

            if (x.MetadataName != y.MetadataName ||
                !TypeSymbolComparer.Equals(x.ContainingType, y.ContainingType) ||
                !NamespaceSymbolComparer.Equals(x.ContainingNamespace, y.ContainingNamespace) ||
                x.Arity != y.Arity)
            {
                return(false);
            }

            for (var i = 0; i < x.Arity; i++)
            {
                if (!TypeSymbolComparer.Equals(x.TypeArguments[i], y.TypeArguments[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        public static bool Equals(ITypeSymbol x, ITypeSymbol y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }

            if (x == null ||
                y == null)
            {
                return(false);
            }

            if (x is INamedTypeSymbol xNamedType &&
                y is INamedTypeSymbol yNamedType)
            {
                return(NamedTypeSymbolComparer.Equals(xNamedType, yNamedType));
            }

            return(x.MetadataName == y.MetadataName &&
                   Equals(x.ContainingType, y.ContainingType) &&
                   NamespaceSymbolComparer.Equals(x.ContainingNamespace, y.ContainingNamespace));
        }
예제 #3
0
        public static bool Equals(ISymbol x, ISymbol y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }

            if (x == null ||
                y == null)
            {
                return(false);
            }

            if (x is IEventSymbol xEvent &&
                y is IEventSymbol yEvent)
            {
                return(EventSymbolComparer.Equals(xEvent, yEvent));
            }

            if (x is IFieldSymbol xField &&
                y is IFieldSymbol yField)
            {
                return(FieldSymbolComparer.Equals(xField, yField));
            }

            if (x is ILocalSymbol xLocal &&
                y is ILocalSymbol yLocal)
            {
                return(LocalSymbolComparer.Equals(xLocal, yLocal));
            }

            if (x is IMethodSymbol xMethod &&
                y is IMethodSymbol yMethod)
            {
                return(MethodSymbolComparer.Equals(xMethod, yMethod));
            }

            if (x is INamedTypeSymbol xNamedType &&
                y is INamedTypeSymbol yNamedType)
            {
                return(NamedTypeSymbolComparer.Equals(xNamedType, yNamedType));
            }

            if (x is INamespaceSymbol xNamespace &&
                y is INamespaceSymbol yNamespace)
            {
                return(NamespaceSymbolComparer.Equals(xNamespace, yNamespace));
            }

            if (x is IParameterSymbol xParameter &&
                y is IParameterSymbol yParameter)
            {
                return(ParameterSymbolComparer.Equals(xParameter, yParameter));
            }

            if (x is IPropertySymbol xProperty &&
                y is IPropertySymbol yProperty)
            {
                return(PropertySymbolComparer.Equals(xProperty, yProperty));
            }

            if (x is ITypeSymbol xType &&
                y is ITypeSymbol yType)
            {
                return(TypeSymbolComparer.Equals(xType, yType));
            }

            return(x.Equals(y));
        }