Пример #1
0
        /// <inheritdoc/>
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            List <TypeData> replacedGenericArguments = null;

            for (int i = 0; i < GenericArguments.Count; i++)
            {
                var currentArgument  = GenericArguments[i];
                var replacedArgument = (TypeData)currentArgument.ReplaceGenericTypeParameters(genericParameters, genericArguments);
                if (replacedArgument == currentArgument)
                {
                    continue;
                }

                if (replacedGenericArguments == null)
                {
                    replacedGenericArguments = new List <TypeData>(GenericArguments);
                }

                replacedGenericArguments[i] = replacedArgument;
            }

            if (replacedGenericArguments != null)
            {
                return(GenericTypeDefinition.GetConstructedGenericTypeData(replacedGenericArguments));
            }

            return(this);
        }
Пример #2
0
        /// <summary>
        /// Replaces all type parameters used by the member with their associated generic arguments specified in a constructed generic type.
        /// </summary>
        /// <param name="genericParameters">The generic parameters being replaced.</param>
        /// <param name="genericArguments">The generic arguments replacing the parameters.</param>
        /// <returns>A new member with the replaced type parameters or the current instance if the member does not use any of the generic parameters.</returns>
#endif
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            if (this.GenericParameters == genericParameters)
            {
                return(this.GetConstructedGenericTypeData(genericArguments));
            }

            return(this);
        }
Пример #3
0
        /// <inheritdoc/>
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            var replacedType = (TypeData)Type.ReplaceGenericTypeParameters(genericParameters, genericArguments);

            if (replacedType == Type)
            {
                return(this);
            }

            return(new PropertyData(Name, Accessibility, MemberFlags, replacedType, IsTypeDynamic, GetMethodAccessibility, SetMethodAccessibility));
        }
Пример #4
0
        /// <summary>
        /// Replaces all type parameters used by the member with their associated generic arguments specified in a constructed generic type.
        /// </summary>
        /// <param name="genericParameters">The generic parameters being replaced.</param>
        /// <param name="genericArguments">The generic arguments replacing the parameters.</param>
        /// <returns>A new member with the replaced type parameters or the current instance if the member does not use any of the generic parameters.</returns>
#endif
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            var replacedParameters = this.Parameters.ReplaceGenericTypeParameters(this.MetadataItemKind, genericParameters, genericArguments);

            if (replacedParameters == this.Parameters)
            {
                return(this);
            }

            return(new ConstructorData(this.Name, this.Accessibility, this.MemberFlags, replacedParameters));
        }
Пример #5
0
        /// <summary>
        /// Replaces all type parameters used by the member with their associated generic arguments specified in a constructed generic type.
        /// </summary>
        /// <param name="genericParameters">The generic parameters being replaced.</param>
        /// <param name="genericArguments">The generic arguments replacing the parameters.</param>
        /// <returns>A new member with the replaced type parameters or the current instance if the member does not use any of the generic parameters.</returns>
#endif
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            var replacedType = (TypeData)this.Type.ReplaceGenericTypeParameters(genericParameters, genericArguments);

            if (replacedType == this.Type)
            {
                return(this);
            }

            return(new EventData(this.Name, this.Accessibility, this.MemberFlags, replacedType));
        }
Пример #6
0
        /// <inheritdoc/>
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            var replacedElementType = (TypeData)ElementType.ReplaceGenericTypeParameters(genericParameters, genericArguments);

            if (replacedElementType == ElementType)
            {
                return(this);
            }

            return(replacedElementType.GetPointerType());
        }
        /// <summary>
        /// Replaces all type parameters used by the member with their associated generic arguments specified in a constructed generic type.
        /// </summary>
        /// <param name="genericParameters">The generic parameters being replaced.</param>
        /// <param name="genericArguments">The generic arguments replacing the parameters.</param>
        /// <returns>A new member with the replaced type parameters or the current instance if the member does not use any of the generic parameters.</returns>
#endif
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            var replacedType = (TypeData)this.Type.ReplaceGenericTypeParameters(genericParameters, genericArguments);

            if (replacedType == this.Type)
            {
                return(this);
            }

            Debug.Fail("It was assumed that constants cannot be generic");
            return(new ConstantData(this.Name, this.Accessibility, this.MemberFlags, replacedType, this.IsTypeDynamic, this.Value));
        }
Пример #8
0
        /// <summary>
        /// Replaces all type parameters used by the member with their associated generic arguments specified in a constructed generic type.
        /// </summary>
        /// <param name="genericParameters">The generic parameters being replaced.</param>
        /// <param name="genericArguments">The generic arguments replacing the parameters.</param>
        /// <returns>A new member with the replaced type parameters or the current instance if the member does not use any of the generic parameters.</returns>
#endif
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            var replacedType       = (TypeData)this.Type.ReplaceGenericTypeParameters(genericParameters, genericArguments);
            var replacedParameters = this.Parameters.ReplaceGenericTypeParameters(this.MetadataItemKind, genericParameters, genericArguments);

            if (replacedType == this.Type &&
                replacedParameters == this.Parameters)
            {
                return(this);
            }

            return(new IndexerData(this.Name, this.Accessibility, this.MemberFlags, replacedType, this.IsTypeDynamic, replacedParameters, this.GetMethodAccessibility, this.SetMethodAccessibility));
        }
Пример #9
0
        /// <inheritdoc/>
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            var replacedType       = (TypeData)Type.ReplaceGenericTypeParameters(genericParameters, genericArguments);
            var replacedParameters = Parameters.ReplaceGenericTypeParameters(MetadataItemKind, genericParameters, genericArguments);

            if (replacedType == Type &&
                replacedParameters == Parameters)
            {
                return(this);
            }

            return(new MethodData(Name, Accessibility, MemberFlags, replacedType, IsTypeDynamic, GenericParameters, IsExtensionMethod, replacedParameters));
        }
        /// <summary>
        /// Replaces all type parameters used by the member with their associated generic arguments specified in a constructed generic type.
        /// </summary>
        /// <param name="genericParameters">The generic parameters being replaced.</param>
        /// <param name="genericArguments">The generic arguments replacing the parameters.</param>
        /// <returns>A new member with the replaced type parameters or the current instance if the member does not use any of the generic parameters.</returns>
#endif
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            for (int i = 0; i < genericParameters.Count; i++)
            {
                if (this == genericParameters[i])
                {
                    Debug.Assert(this.GenericParameterPosition == i, "We are expecting the generic argument to be in its proper position.");
                    return(genericArguments[i]);
                }
            }

            return(this);
        }
Пример #11
0
        internal bool DoesMatch(GenericTypeParameterCollection other)
        {
            if (this.Count != other.Count)
            {
                return(false);
            }

            for (int i = 0; i < this.Count; i++)
            {
                if (this[i].DoesMatch(other[i]) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #12
0
        /// <summary>
        /// Replaces all type parameters used by the member with their associated generic arguments specified in a constructed generic type.
        /// </summary>
        /// <param name="genericParameters">The generic parameters being replaced.</param>
        /// <param name="genericArguments">The generic arguments replacing the parameters.</param>
        /// <returns>A new member with the replaced type parameters or the current instance if the member does not use any of the generic parameters.</returns>
#endif
        internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            var replacedElementType = (TypeData)this.ElementType.ReplaceGenericTypeParameters(genericParameters, genericArguments);

            if (replacedElementType == this.ElementType)
            {
                return(this);
            }

            return
                (replacedElementType.GetArrayType(this.ArrayRank) ??
                 new ArrayTypeData(
                     this.Name,
                     this.Accessibility,
                     this.MemberFlags,
                     this.TypeKind,
                     replacedElementType,
                     this.ArrayRank));
        }
Пример #13
0
 internal MethodData(string name, Accessibility accessibility, MemberFlags memberFlags, TypeData type, bool isTypeDynamic, GenericTypeParameterCollection genericParameters, bool isExtensionMethod, ParameterCollection parameters)
     : base(name, accessibility, memberFlags, type, isTypeDynamic, parameters)
 {
     GenericParameters = genericParameters;
     IsExtensionMethod = isExtensionMethod;
 }
 internal ImplementedInterfacesCollection ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
 {
     return(new ImplementedInterfacesCollection(this.Select(im => (DeclaringTypeData)im.ReplaceGenericTypeParameters(genericParameters, genericArguments))));
 }
Пример #15
0
 /// <inheritdoc/>
 internal override MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments) =>
 GenericParameters == genericParameters?GetConstructedGenericTypeData(genericArguments) : (MemberDataBase)this;
Пример #16
0
        /// <summary>
        /// Replaces all type parameters used by the member with their associated generic arguments specified in a constructed generic type.
        /// </summary>
        /// <param name="declaringMemberKind">The type of member owning the parameter collection.</param>
        /// <param name="genericParameters">The generic parameters being replaced.</param>
        /// <param name="genericArguments">The generic arguments replacing the parameters.</param>
        /// <returns>A new member with the replaced type parameters or the current instance if the member does not use any of the generic parameters.</returns>
#endif
        internal ParameterData ReplaceGenericTypeParameters(MetadataItemKinds declaringMemberKind, GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            var replacedType = (TypeData)this.Type.ReplaceGenericTypeParameters(genericParameters, genericArguments);

            if (replacedType == this.Type)
            {
                return(this);
            }

            return(new ParameterData(declaringMemberKind, this.Name, replacedType, this.Modifer, _flags, this.DefaultValue));
        }
        /// <summary>
        /// Replaces all type parameters used by the member with their associated generic arguments specified in a constructed generic type.
        /// </summary>
        /// <param name="genericParameters">The generic parameters being replaced.</param>
        /// <param name="genericArguments">The generic arguments replacing the parameters.</param>
        /// <returns>A new member with the replaced type parameters or the current instance if the member does not use any of the generic parameters.</returns>
#endif
        internal abstract MemberDataBase ReplaceGenericTypeParameters(GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments);
        /// <summary>
        /// Replaces all type parameters used by the member with their associated generic arguments specified in a constructed generic type.
        /// </summary>
        /// <param name="declaringMemberKind">The type of member owning the parameter collection.</param>
        /// <param name="genericParameters">The generic parameters being replaced.</param>
        /// <param name="genericArguments">The generic arguments replacing the parameters.</param>
        /// <returns>A new member with the replaced type parameters or the current instance if the member does not use any of the generic parameters.</returns>
#endif
        internal ParameterCollection ReplaceGenericTypeParameters(MetadataItemKinds declaringMemberKind, GenericTypeParameterCollection genericParameters, GenericTypeArgumentCollection genericArguments)
        {
            ParameterCollection replacedParameters = null;

            for (int i = 0; i < this.Count; i++)
            {
                var currentParameter  = this[i];
                var replacedParameter = currentParameter.ReplaceGenericTypeParameters(declaringMemberKind, genericParameters, genericArguments);
                if (replacedParameter == currentParameter)
                {
                    continue;
                }

                if (replacedParameters == null)
                {
                    replacedParameters = new ParameterCollection();
                    replacedParameters._parameters.AddRange(_parameters);
                }

                replacedParameters._parameters[i] = replacedParameter;
            }

            return(replacedParameters ?? this);
        }