コード例 #1
0
        protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct)
        {
            AddTypeEquivalentTypes(Context.DocumentService, analyzedTypes[0], analyzedTypes);
            foreach (var declType in analyzedTypes)
            {
                var type = declType.BaseType.ResolveTypeDef();
                while (!(type is null))
                {
                    foreach (var property in type.Properties)
                    {
                        if (TypesHierarchyHelpers.IsBaseProperty(property, analyzedProperty))
                        {
                            var anyAccessor = property.GetMethod ?? property.SetMethod;
                            if (anyAccessor is null)
                            {
                                continue;
                            }
                            yield return(new PropertyNode(property)
                            {
                                Context = Context
                            });

                            yield break;
                        }
                    }
                    type = type.BaseType.ResolveTypeDef();
                }
            }
        }
コード例 #2
0
        private IEnumerable <AnalyzerTreeNode> FindReferencesInType(TypeDef type)
        {
            if (!TypesHierarchyHelpers.IsBaseType(analyzedProperty.DeclaringType, type, resolveTypeArguments: false))
            {
                yield break;
            }

            foreach (PropertyDef property in type.Properties)
            {
                if (TypesHierarchyHelpers.IsBaseProperty(analyzedProperty, property))
                {
                    MethodDef anyAccessor = property.GetMethod ?? property.SetMethod;
                    bool      hidesParent = !anyAccessor.IsVirtual ^ anyAccessor.IsNewSlot;
                    var       node        = new AnalyzedPropertyTreeNode(property, hidesParent ? "(hides) " : "");
                    node.Language = this.Language;
                    yield return(node);
                }
            }
        }
コード例 #3
0
        protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct)
        {
            //get base type (if any)
            if (analyzedProperty.DeclaringType.BaseType == null)
            {
                yield break;
            }
            ITypeDefOrRef baseType = analyzedProperty.DeclaringType.BaseType;

            while (baseType != null)
            {
                //only typedef has a Properties property
                if (baseType is TypeDef)
                {
                    TypeDef def = (TypeDef)baseType;
                    foreach (PropertyDef property in def.Properties)
                    {
                        if (TypesHierarchyHelpers.IsBaseProperty(property, analyzedProperty))
                        {
                            MethodDef anyAccessor = property.GetMethod ?? property.SetMethod;
                            if (anyAccessor == null)
                            {
                                continue;
                            }
                            yield return(new PropertyNode(property)
                            {
                                Context = Context
                            });

                            yield break;
                        }
                    }
                    baseType = def.BaseType;
                }
                else
                {
                    //try to resolve the TypeRef
                    //will be null if resolving failed
                    baseType = baseType.Resolve();
                }
            }
        }
コード例 #4
0
        IEnumerable <SharpTreeNode> FindReferences(LoadedAssembly asm, CancellationToken ct)
        {
            string asmName      = asm.AssemblyDefinition.Name.Name;
            string name         = analyzedProperty.Name;
            string declTypeName = analyzedProperty.DeclaringType.FullName;

            foreach (TypeDefinition type in TreeTraversal.PreOrder(asm.AssemblyDefinition.MainModule.Types, t => t.NestedTypes))
            {
                ct.ThrowIfCancellationRequested();

                SharpTreeNode newNode = null;
                try {
                    if (!TypesHierarchyHelpers.IsBaseType(analyzedProperty.DeclaringType, type, resolveTypeArguments: false))
                    {
                        continue;
                    }

                    foreach (PropertyDefinition property in type.Properties)
                    {
                        ct.ThrowIfCancellationRequested();

                        if (TypesHierarchyHelpers.IsBaseProperty(analyzedProperty, property))
                        {
                            MethodDefinition anyAccessor = property.GetMethod ?? property.SetMethod;
                            bool             hidesParent = !anyAccessor.IsVirtual ^ anyAccessor.IsNewSlot;
                            newNode = new AnalyzedPropertyTreeNode(property, hidesParent ? "(hides) " : "");
                        }
                    }
                }
                catch (ReferenceResolvingException) {
                    // ignore this type definition.
                }
                if (newNode != null)
                {
                    yield return(newNode);
                }
            }
        }
コード例 #5
0
        IEnumerable <AnalyzerTreeNodeData> FindReferencesInType(TypeDef type)
        {
            if (!TypesHierarchyHelpers.IsBaseType(analyzedProperty.DeclaringType, type, resolveTypeArguments: false))
            {
                yield break;
            }

            foreach (PropertyDef property in type.Properties)
            {
                if (TypesHierarchyHelpers.IsBaseProperty(analyzedProperty, property))
                {
                    MethodDef anyAccessor = property.GetMethod ?? property.SetMethod;
                    if (anyAccessor == null)
                    {
                        continue;
                    }
                    bool hidesParent = !anyAccessor.IsVirtual ^ anyAccessor.IsNewSlot;
                    yield return(new PropertyNode(property, hidesParent)
                    {
                        Context = Context
                    });
                }
            }
        }