private IEnumerable <SharpTreeNode> FindReferences(LoadedAssembly asm, CancellationToken ct)
        {
            string asmName      = asm.AssemblyDefinition.Name.Name;
            string name         = analyzedEvent.Name;
            string declTypeName = analyzedEvent.DeclaringType.FullName;

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

                if (!TypesHierarchyHelpers.IsBaseType(analyzedEvent.DeclaringType, type, resolveTypeArguments: false))
                {
                    continue;
                }

                foreach (EventDefinition eventDef in type.Events)
                {
                    ct.ThrowIfCancellationRequested();

                    if (TypesHierarchyHelpers.IsBaseEvent(analyzedEvent, eventDef))
                    {
                        MethodDefinition anyAccessor = eventDef.AddMethod ?? eventDef.RemoveMethod;
                        bool             hidesParent = !anyAccessor.IsVirtual ^ anyAccessor.IsNewSlot;
                        yield return(new AnalyzedEventTreeNode(eventDef, hidesParent ? "(hides) " : ""));
                    }
                }
            }
        }
Exemplo n.º 2
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 eventDef in type.Events)
                    {
                        if (TypesHierarchyHelpers.IsBaseEvent(eventDef, analyzedEvent))
                        {
                            var anyAccessor = eventDef.AddMethod ?? eventDef.RemoveMethod;
                            if (anyAccessor is null)
                            {
                                continue;
                            }
                            yield return(new EventNode(eventDef)
                            {
                                Context = Context
                            });

                            yield break;
                        }
                    }
                    type = type.BaseType.ResolveTypeDef();
                }
            }
        }
Exemplo n.º 3
0
        private IEnumerable<AnalyzerTreeNode> FindReferencesInType(TypeDefinition type)
        {
            if (!TypesHierarchyHelpers.IsBaseType(analyzedEvent.DeclaringType, type, resolveTypeArguments: false))
                yield break;

            foreach (EventDefinition eventDef in type.Events) {
                if (TypesHierarchyHelpers.IsBaseEvent(analyzedEvent, eventDef)) {
                    MethodDefinition anyAccessor = eventDef.AddMethod ?? eventDef.RemoveMethod;
                    bool hidesParent = !anyAccessor.IsVirtual ^ anyAccessor.IsNewSlot;
                    var node = new AnalyzedEventTreeNode(eventDef, hidesParent ? "(hides) " : "");
                    node.Language = this.Language;
                    yield return node;
                }
            }
        }
Exemplo n.º 4
0
        protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct)
        {
            //get base type (if any)
            if (analyzedEvent.DeclaringType.BaseType == null)
            {
                yield break;
            }
            ITypeDefOrRef baseType = analyzedEvent.DeclaringType.BaseType;

            while (baseType != null)
            {
                //only typedef has a Events property
                if (baseType is TypeDef)
                {
                    TypeDef def = (TypeDef)baseType;
                    foreach (EventDef eventDef in def.Events)
                    {
                        if (TypesHierarchyHelpers.IsBaseEvent(eventDef, analyzedEvent))
                        {
                            MethodDef anyAccessor = eventDef.AddMethod ?? eventDef.RemoveMethod;
                            if (anyAccessor == null)
                            {
                                continue;
                            }
                            yield return(new EventNode(eventDef)
                            {
                                Context = Context
                            });

                            yield break;
                        }
                    }
                    baseType = def.BaseType;
                }
                else
                {
                    //try to resolve the TypeRef
                    //will be null if resolving failed
                    baseType = baseType.Resolve();
                }
            }
        }
Exemplo n.º 5
0
        IEnumerable <IAnalyzerTreeNodeData> FindReferencesInType(TypeDef type)
        {
            if (!TypesHierarchyHelpers.IsBaseType(analyzedEvent.DeclaringType, type, resolveTypeArguments: false))
            {
                yield break;
            }

            foreach (EventDef eventDef in type.Events)
            {
                if (TypesHierarchyHelpers.IsBaseEvent(analyzedEvent, eventDef))
                {
                    MethodDef anyAccessor = eventDef.AddMethod ?? eventDef.RemoveMethod;
                    if (anyAccessor == null)
                    {
                        continue;
                    }
                    bool hidesParent = !anyAccessor.IsVirtual ^ anyAccessor.IsNewSlot;
                    yield return(new EventNode(eventDef, hidesParent)
                    {
                        Context = Context
                    });
                }
            }
        }