Esempio n. 1
0
        public bool Equals(EcmaDesc other)
        {
            if (other == null)
            {
                return(false);
            }

            if (NestedType == null ^ other.NestedType == null ||
                ArrayDimensions == null ^ other.ArrayDimensions == null ||
                GenericTypeArguments == null ^ other.GenericTypeArguments == null ||
                GenericMemberArguments == null ^ other.GenericMemberArguments == null ||
                MemberArguments == null ^ other.MemberArguments == null ||
                ExplicitImplMember == null ^ other.ExplicitImplMember == null)
            {
                return(false);
            }

            return(other != null &&
                   DescKind == other.DescKind &&
                   TypeName == other.TypeName &&
                   Namespace == other.Namespace &&
                   MemberName == other.MemberName &&
                   (NestedType == null || NestedType.Equals(other.NestedType)) &&
                   (ArrayDimensions == null || ArrayDimensions.SequenceEqual(other.ArrayDimensions)) &&
                   (GenericTypeArguments == null || GenericTypeArguments.SequenceEqual(other.GenericTypeArguments)) &&
                   (GenericMemberArguments == null || GenericMemberArguments.SequenceEqual(other.GenericMemberArguments)) &&
                   (MemberArguments == null || MemberArguments.SequenceEqual(other.MemberArguments)) &&
                   Etc == other.Etc &&
                   EtcFilter == other.EtcFilter &&
                   (ExplicitImplMember == null || ExplicitImplMember.Equals(other.ExplicitImplMember)));
        }
Esempio n. 2
0
        public bool Equals(MyType other)
        {
            if (ReferenceEquals(other, this))
            {
                return(true);
            }

            return(other != null &&
                   Name == other.Name &&
                   Attributes.SequenceEqual(other.Attributes) &&
                   GenericTypeArguments.SequenceEqual(other.GenericTypeArguments) &&
                   TypeKind == other.TypeKind &&
                   NestedElements.SequenceEqual(other.NestedElements));
        }
Esempio n. 3
0
        public override string ToString()
        {
            var name = Name;

            if (!GenericTypeArguments.Any())
            {
                return(name);
            }

            var tokens = new List <string>();

            foreach (var arg in GenericTypeArguments)
            {
                tokens.Add(arg.ToString());
            }

            if (name.StartsWith("Nullable", StringComparison.InvariantCultureIgnoreCase))
            {
                return($"{tokens[0]}?");
            }

            return($"{name}<{string.Join(", ", tokens)}>");
        }
Esempio n. 4
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public string MakeGenericName(string openBracket, string closeBracket, string commaSeparator)
        {
            if (!IsGenericType)
            {
                return(this.Name);
            }

            if (IsGenericTypeDefinition)
            {
                return(
                    this.Name +
                    openBracket +
                    string.Join(commaSeparator, GenericTypeParameters.Select(t => t.Name)) +
                    closeBracket);
            }
            else
            {
                return(
                    this.Name +
                    openBracket +
                    string.Join(commaSeparator, GenericTypeArguments.Select(t => t.MakeGenericName(openBracket, closeBracket, commaSeparator))) +
                    closeBracket);
            }
        }