Exemplo n.º 1
0
        private void DoSetChains(string root, MethodDefinition caller, CallGraph graph, List <MethodDefinition> chain, bool multiple, int depth)
        {
//			if (depth > 12)			// this can't be too large or the rule takes a very long time to run
//				return false;

            // For each method the caller calls,
            IEnumerable <MethodReference> callees = graph.GetCalls(caller);

            if (callees != null)
            {
                foreach (MethodReference callee in callees)
                {
                    // if it's a method in the assembly we're testing,
                    MethodState state;
                    if (m_methods.TryGetValue(callee, out state))
                    {
                        // and we haven't already called it from our root,
                        if (!state.IsCalledFrom(root))
                        {
                            // then update it's call chain and update all the methods it calls.
                            List <MethodDefinition> schain = new List <MethodDefinition>(chain.Count + 1);
                            schain.AddRange(chain);
                            schain.Add(state.Method);

                            state.SetCallChain(root, schain, multiple);
                            DoSetChains(root, state.Method, graph, schain, multiple, depth + 1);

                            if (m_requiredSafeTypes.IndexOf(state.Method.DeclaringType) < 0)
                            {
                                m_requiredSafeTypes.Add(state.Method.DeclaringType);
                            }
                        }
                    }
                }
            }
        }