コード例 #1
0
        void ProcessType(TypeDefinition type)
        {
            if (!HasIndirectCallers(type))
            {
                AddCustomAttribute(type);
                return;
            }

            //
            // We mark everything, otherwise we would need to check full visibility
            // hierarchy (e.g. public method inside private type)
            //
            foreach (var method in type.Methods)
            {
                if (!Annotations.IsIndirectlyCalled(method))
                {
                    AddCustomAttribute(method);
                }
            }

            foreach (var nested in type.NestedTypes)
            {
                ProcessType(nested);
            }
        }
コード例 #2
0
        bool HasIndirectCallers(TypeDefinition type)
        {
            foreach (var method in type.Methods)
            {
                if (Annotations.IsIndirectlyCalled(method))
                {
                    return(true);
                }
            }

            if (type.HasNestedTypes)
            {
                foreach (var nested in type.NestedTypes)
                {
                    if (HasIndirectCallers(nested))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }