示例#1
0
        /// <summary>
        /// Indicates whether a new member of the same type and name is logically the same member as the current member, just from a newer build.
        /// </summary>
        /// <param name="newMember">The new member to compare.</param>
        /// <param name="newAssemblyFamily">The assembly family in which new assemblies reside.</param>
        /// <param name="ignoreNewOptionalParameters">
        /// Indicates whether to ignore any new parameters at the end of the collection which are optional when comparing.
        /// </param>
#endif
        private bool IsEquivalentToNewMember(IndexerData newMember, AssemblyFamily newAssemblyFamily, bool ignoreNewOptionalParameters)
        {
            if (base.IsEquivalentToNewMember(newMember, newAssemblyFamily) == false)
            {
                return(false);
            }

            return(this.Parameters.IsEquivalentToNewParameters(newMember.Parameters, newAssemblyFamily, ignoreNewOptionalParameters));
        }
        internal static MemberDataBase MemberDataFromReflection(MemberReference member, DeclaringTypeData declaringType)
        {
            try
            {
                switch (member.MetadataToken.TokenType)
                {
                case TokenType.TypeDef:
                    return(declaringType.AssemblyData.GetTypeData((TypeDefinition)member));

                case TokenType.Method:
                {
                    var method = (MethodDefinition)member;

                    if (method.IsConstructor)
                    {
                        return(ConstructorData.ConstructorDataFromReflection(method, declaringType));
                    }

                    if (method.IsSpecialName)
                    {
                        if (method.IsPublic && method.IsStatic && method.Name.StartsWith("op_"))
                        {
                            return(new OperatorData(method, declaringType));
                        }

                        return(null);
                    }

                    return(MethodData.MethodDataFromReflection(method, declaringType));
                }

                case TokenType.Field:
                {
                    var field = (FieldDefinition)member;

                    // Filter out the "value__" field on enums
                    if (declaringType.TypeKind == TypeKind.Enum && field.IsStatic == false)
                    {
                        return(null);
                    }

                    if (field.IsLiteral && field.IsInitOnly == false)
                    {
                        return(ConstantData.ConstantDataFromReflection(field, declaringType));
                    }

                    return(FieldData.FieldDataFromReflection(field, declaringType));
                }

                case TokenType.Event:
                    return(EventData.EventDataFromReflection((EventDefinition)member, declaringType));

                case TokenType.Property:
                {
                    var property = (PropertyDefinition)member;
                    if (property.HasParameters)
                    {
                        return(IndexerData.IndexerDataFromReflection(property, declaringType));
                    }

                    return(PropertyData.PropertyDataFromReflection(property, declaringType));
                }

                default:
                    Debug.Fail("Unknown TokenType: " + member.MetadataToken.TokenType);
                    return(null);
                }
            }
            catch (AssemblyResolutionException ex)
            {
                // TODO: How should we handle this? This happens when an assembly reference cant be found.
                Debug.Fail("Could not load assembly: " + ex.ToString());
                return(null);
            }
        }
 /// <summary>
 /// The visit implementation for <see cref="IndexerData"/> instances.
 /// </summary>
 public virtual void VisitIndexerData(IndexerData item)
 {
     this.DefaultVisit(item);
 }