Esempio n. 1
0
        public override IEnumerable <TreeNodeData> CreateChildren()
        {
            if (analyzedMethod.HasBody)
            {
                yield return(new MethodUsesNode(analyzedMethod));
            }

            if (analyzedMethod.IsVirtual && !(analyzedMethod.IsNewSlot && analyzedMethod.IsFinal))
            {
                yield return(new VirtualMethodUsedByNode(analyzedMethod));
            }
            else
            {
                yield return(new MethodUsedByNode(analyzedMethod));
            }

            if (MethodOverriddenNode.CanShow(analyzedMethod))
            {
                yield return(new MethodOverriddenNode(analyzedMethod));
            }

            if (MethodOverridesNode.CanShow(analyzedMethod))
            {
                yield return(new MethodOverridesNode(analyzedMethod));
            }

            if (InterfaceMethodImplementedByNode.CanShow(analyzedMethod))
            {
                yield return(new InterfaceMethodImplementedByNode(analyzedMethod));
            }
        }
        IEnumerable <AnalyzerTreeNodeData> FindReferencesInType(TypeDef type)
        {
            if (analyzedMethod is null)
            {
                yield break;
            }
            if (type.IsInterface)
            {
                yield break;
            }
            var implementedInterfaceRef = InterfaceMethodImplementedByNode.GetInterface(type, analyzedMethod.DeclaringType);

            if (implementedInterfaceRef is null)
            {
                yield break;
            }

            foreach (EventDef ev in type.Events.Where(e => e.Name.EndsWith(analyzedEvent.Name)))
            {
                var accessor = GetAccessor(ev);
                // Don't include abstract accessors, they don't implement anything
                if (accessor is null || !accessor.IsVirtual || accessor.IsAbstract)
                {
                    continue;
                }
                if (accessor.HasOverrides && accessor.Overrides.Any(m => CheckEquals(m.MethodDeclaration.ResolveMethodDef(), analyzedMethod)))
                {
                    yield return(new EventNode(ev)
                    {
                        Context = Context
                    });

                    yield break;
                }
            }

            foreach (EventDef ev in type.Events.Where(e => e.Name == analyzedEvent.Name))
            {
                var accessor = GetAccessor(ev);
                // Don't include abstract accessors, they don't implement anything
                if (accessor is null || !accessor.IsVirtual || accessor.IsAbstract)
                {
                    continue;
                }
                if (TypesHierarchyHelpers.MatchInterfaceMethod(accessor, analyzedMethod, implementedInterfaceRef))
                {
                    yield return(new EventNode(ev)
                    {
                        Context = Context
                    });

                    yield break;
                }
            }
        }