Example #1
0
		private bool DoFoundBadSetter(CallGraph graph, MethodReference method, List<string> chain)
		{
			if (m_visited.IndexOf(method) >= 0)
				return false;
			m_visited.Add(method);
			
			bool found = false;
			Log.DebugLine(this, "checking {0}", method);	

			if (m_unlocked.IndexOf(method) >= 0 && m_setters.IndexOf(method) >= 0) 
			{
				Log.DebugLine(this, "it's a setter");	
				found = true;
			}
			else
			{
				foreach (MethodReference callee in graph.Calls(method))
				{
					Log.Indent();
					if (DoFoundBadSetter(graph, callee, chain))
					{
						found = true;
						Log.Unindent();
						break;
					}
					Log.Unindent();
				}
			}
			
			if (found)
				chain.Insert(0, method.ToString());
			
			return found;
		}
Example #2
0
		private bool DoCallsExternal(MethodReference method, Entry entry, CallGraph graph, List<string> chain, int depth, ref string name)
		{
			if (depth > 8)			// this can't be too large or the rule takes a very long time to run
				return false;
			
			chain.Add(method.ToString());
			if (entry.ExternalCalls.ContainsKey(method))
			{
				name = entry.ExternalCalls[method];
				return true;
			}
			
			foreach (MethodReference candidate in graph.Calls(method))
			{
				if (DoCallsExternal(candidate, entry, graph, chain, depth + 1, ref name))
					return true;
			}
			chain.RemoveAt(chain.Count - 1);
			
			return false;
		}
Example #3
0
		private bool DoCallsLock(MethodReference method, FieldReference field, Entry entry, CallGraph graph, List<string> chain, int depth)
		{
			if (depth > 8)			// this can't be too large or the rule takes a very long time to run
				return false;
			
			chain.Add(method.ToString());
			if (entry.Locked.ContainsKey(method) && entry.Locked[method].IndexOf(field) >= 0)
			{
				return true;
			}
			
			foreach (MethodReference candidate in graph.Calls(method))
			{
				if (DoCallsLock(candidate, field, entry, graph, chain, depth + 1))
					return true;
			}
			chain.RemoveAt(chain.Count - 1);
			
			return false;
		}