예제 #1
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            foreach (KeyValuePair <TypeReference, List <TypeReference> > entry in m_table)
            {
                TypeReference type    = entry.Key;
                string        details = string.Empty;
                foreach (TypeReference r in entry.Value)
                {
                    if (string.Compare(type.FullName, r.FullName) < 0)                          // tie-breaker which prevents us from reporting the same error twice
                    {
                        List <TypeReference> refs = null;
                        if (m_table.TryGetValue(r, out refs) && refs.IndexOf(type) >= 0)
                        {
                            details = string.Format("{0}{1} ", details, r);
                        }
                    }
                }

                if (details.Length > 0)
                {
                    details = string.Format("{0} <-> {1} ", type.FullName, details);
                    Log.DebugLine(this, details);

                    TypeDefinition t = Cache.FindType(type);
                    if (t != null)
                    {
                        Reporter.TypeFailed(t, CheckID, details);
                    }
                }
            }
        }
예제 #2
0
		public void VisitFini(EndTesting end)
		{
			Unused.Value = end;

			if (m_foundAdd && !m_foundOvf)
				Reporter.AssemblyFailed(Cache.Assembly, CheckID, string.Empty);
		}
예제 #3
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            string details = string.Empty;

            foreach (KeyValuePair <string, List <string> > entry in m_table)
            {
                if (entry.Value.Count > 4)
                {
                    string prefix = DoGetPrefix(entry.Key, entry.Value);
                    if (prefix != null)
                    {
                        if (details.Length > 0)
                        {
                            details += Environment.NewLine;
                        }
                        details += string.Format("{0} classes use \"{1}\"", entry.Key, prefix);
                    }
                }
            }

            if (details.Length > 0)
            {
                Log.DebugLine(this, details);
                Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
            }
        }
예제 #4
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            if (m_methods.Count > 0)
            {
                Log.TraceLine(this, "{0} methods were not called", m_methods.Count);
                CompareNames comparer = new CompareNames();
                m_methods.Sort(comparer);

                StringBuilder builder = new StringBuilder();
                builder.AppendLine("Methods: ");
                for (int i = 0; i < m_methods.Count; ++i)
                {
                    builder.Append(m_methods[i].ToString());
                    if (i + 1 < m_methods.Count)
                    {
                        builder.AppendLine();
                    }
                }

                string details = builder.ToString();

                Log.TraceLine(this, details);
                Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
            }
        }
예제 #5
0
		public void VisitFini(EndTesting end)
		{						
			Unused.Value = end;
			
			string details = string.Empty;
			
			foreach (KeyValuePair<string, List<string>> entry in m_table)
			{
				if (entry.Value.Count > 4)
				{
					string prefix = DoGetPrefix(entry.Key, entry.Value);
					if (prefix != null)
					{
						if (details.Length > 0)
							details += Environment.NewLine;
						details += string.Format("{0} classes use \"{1}\"", entry.Key, prefix);
					}
				}
			}
			
			if (details.Length > 0)
			{
				Log.DebugLine(this, details); 
				Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
			}
		}
예제 #6
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            if (m_foundAdd && !m_foundOvf)
            {
                Reporter.AssemblyFailed(Cache.Assembly, CheckID, string.Empty);
            }
        }
예제 #7
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            if (m_details.Length > 0)
            {
                m_details = "Asserting: " + m_details;
                Reporter.AssemblyFailed(Cache.Assembly, CheckID, m_details);
            }
        }
예제 #8
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            if (m_callsRun && m_callsExit)
            {
                m_details = "Calls Exit: " + m_details;
                Log.DebugLine(this, m_details);
                Reporter.AssemblyFailed(Cache.Assembly, CheckID, m_details);
            }
        }
예제 #9
0
		public void VisitFini(EndTesting end)
		{
			Unused.Value = end;
			
			if (m_callsRun && m_callsExit)
			{
				m_details = "Calls Exit: " + m_details;
				Log.DebugLine(this, m_details); 
				Reporter.AssemblyFailed(Cache.Assembly, CheckID, m_details);
			}
		}
예제 #10
0
		public void VisitFini(EndTesting end)
		{		
			Unused.Value = end;
			
			if (m_foundRun)
			{
				if (!m_foundStyle || !m_foundCompatible)
				{
					Reporter.AssemblyFailed(Cache.Assembly, CheckID, string.Empty);
				}
			}
		}
예제 #11
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            if (m_foundRun)
            {
                if (!m_foundStyle || !m_foundCompatible)
                {
                    Reporter.AssemblyFailed(Cache.Assembly, CheckID, string.Empty);
                }
            }
        }
예제 #12
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            if (m_bad.Count > 0)
            {
                string details = "Bad Calls: " + string.Join(Environment.NewLine, m_bad.ToArray());
                Log.DebugLine(this, details);

                Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
            }
        }
예제 #13
0
        // This is visited after methods.
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            DBC.Assert(m_state == State.Calls, "state is {0}", m_state);
            m_state = State.End;

            if (m_types.Count > 0)
            {
                string details = "Unused: " + string.Join(Environment.NewLine, m_types.ToArray());
                Log.DebugLine(this, details);

                Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
            }
        }
예제 #14
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            List <string> bad = new List <string>();

            DoGetMatches(bad, m_namespaces, "Namespaces: ");
            DoGetMatches(bad, m_types, "Types: ");

            if (bad.Count > 0)
            {
                string details = string.Join(Environment.NewLine, bad.ToArray());
                Log.DebugLine(this, details);
                Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
            }
        }
예제 #15
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            foreach (KeyValuePair <MethodDefinition, Entry> entry in m_table)
            {
                if (!entry.Value.CallsUri)
                {
                    string details = "Method: " + entry.Key.Name;
                    Log.DebugLine(this, details);

                    TypeDefinition type = Cache.FindType(entry.Key.DeclaringType);
                    Reporter.TypeFailed(type, CheckID, details);
                }
            }
        }
예제 #16
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            if (Cache.Assembly.EntryPoint != null)
            {
                Log.DebugLine(this, "entry point: {0}", Cache.Assembly.EntryPoint);

                if (m_details.Length != 0)
                {
                    m_details = "Public types: " + m_details;

                    Log.DebugLine(this, m_details);
                    Reporter.AssemblyFailed(Cache.Assembly, CheckID, m_details);
                }
            }
        }
예제 #17
0
		public void VisitFini(EndTesting end)
		{
			Unused.Value = end;
			
			if (Cache.Assembly.EntryPoint != null)
			{
				Log.DebugLine(this, "entry point: {0}", Cache.Assembly.EntryPoint);

				if (m_details.Length != 0)
				{
					m_details = "Public types: " + m_details;
					
					Log.DebugLine(this, m_details);
					Reporter.AssemblyFailed(Cache.Assembly, CheckID, m_details);
				}
			}
		}
예제 #18
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            Dictionary <TypeDefinition, List <string> > bad = new Dictionary <TypeDefinition, List <string> >();
            List <TypeDefinition> hasCalls = new List <TypeDefinition>();

            foreach (KeyValuePair <MethodReference, Info> entry in m_candidates)
            {
                // We have a violation if a candidate method is only
                // called by its declaring type or a subclass (if it's not called at
                // all we'll let the UnusedMethod rule handle it).
                if (entry.Value.CalledBy != null)
                {
                    if (entry.Value.CalledBy == entry.Value.Defined || entry.Value.CalledBy.IsSubclassOf(entry.Value.Defined, Cache))
                    {
                        List <string> methods;

                        if (!bad.TryGetValue(entry.Value.Defined, out methods))
                        {
                            methods = new List <string>();
                            bad.Add(entry.Value.Defined, methods);
                        }

                        methods.Add(entry.Key.ToString());
                    }
                    else
                    {
                        hasCalls.Add(entry.Value.Defined);
                    }
                }
            }

            foreach (KeyValuePair <TypeDefinition, List <string> > entry2 in bad)
            {
                if (hasCalls.IndexOf(entry2.Key) < 0)
                {
                    string details = "Methods: " + string.Join(Environment.NewLine, entry2.Value.ToArray());
                    Log.DebugLine(this, details);
                    Reporter.TypeFailed(entry2.Key, CheckID, details);
                }
            }
        }
예제 #19
0
        public void VisitEnd(EndTesting end)
        {
            Unused.Value = end;

            if (m_downloader.Complete)
            {
                string[] parts = m_downloader.Contents.Trim().Split('.');
                int      newMajor, newMinor;

                if (parts.Length == 2 && int.TryParse(parts[0], out newMajor) && int.TryParse(parts[1], out newMinor))
                {
                    Version installed = Assembly.GetExecutingAssembly().GetName().Version;

                    if (newMajor > installed.Major || (newMajor == installed.Major && newMinor > installed.Minor))
                    {
                        string details = string.Empty;
                        details += "Latest Version:    " + m_downloader.Contents + Environment.NewLine;
                        details += "Installed Version: " + installed.Major + "." + installed.Minor;
                        Log.DebugLine(this, details);

                        Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
                    }
                    else
                    {
                        Log.DebugLine(this, "installed version is OK");
                        Log.DebugLine(this, "installed: {0}", installed);
                        Log.DebugLine(this, "latest: {0}.{1}", newMajor, newMinor);
                    }
                }
                else
                {
                    Log.ErrorLine(this, "Bad download: '{0}'", m_downloader.Contents);
                }
            }
            else
            {
                TimeSpan duration = DateTime.Now - m_startTime;
                Log.WarningLine(this, "NewVersionRule wasn't able to download the version number within {0:0.000} seconds", duration.TotalSeconds);

                m_downloader.Cancel();
            }
        }
예제 #20
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            string header = "Match:  ";

            foreach (List <MethodCapture> methods in m_table.Values)
            {
                List <int> found = new List <int>();

                for (int i = 0; i < methods.Count; ++i)
                {
                    List <string> matches = new List <string>();

                    for (int j = i + 1; j < methods.Count; ++j)
                    {
                        if (found.IndexOf(j) < 0)
                        {
                            Log.DebugLine(this, "checking {0} and {1}", methods[i].Method, methods[j].Method);

                            if (DoMatch(methods[i], methods[j]))
                            {
                                Log.DebugLine(this, "   matched");
                                matches.Add(methods[j].Method.ToString());
                                found.Add(j);
                            }
                        }
                    }

                    if (matches.Count > 0)
                    {
                        string[] strs    = Array.ConvertAll(matches.ToArray(), s => s + "   ");
                        string   details = string.Format("{0}{1}", header, string.Join(Environment.NewLine, strs));

                        Log.DebugLine(this, details);
                        Reporter.MethodFailed(methods[i].Method, CheckID, 0, details);
                    }
                }
            }
        }
예제 #21
0
		public void VisitFini(EndTesting end)
		{
			Unused.Value = end;
			
			string header = "Match:  ";
			
			foreach (List<MethodCapture> methods in m_table.Values)
			{
				List<int> found = new List<int>();
						
				for (int i = 0; i < methods.Count; ++i)
				{
					List<string> matches = new List<string>();

					for (int j = i + 1; j < methods.Count; ++j)
					{
						if (found.IndexOf(j) < 0)
						{
							Log.DebugLine(this, "checking {0} and {1}", methods[i].Method, methods[j].Method);
						
							if (DoMatch(methods[i], methods[j]))
							{
								Log.DebugLine(this, "   matched");
								matches.Add(methods[j].Method.ToString());
								found.Add(j);
							}
						}
					}
					
					if (matches.Count > 0)
					{						
						string[] strs = Array.ConvertAll(matches.ToArray(), s => s + "   ");
						string details = string.Format("{0}{1}", header, string.Join(Environment.NewLine, strs));
						
						Log.DebugLine(this, details);
						Reporter.MethodFailed(methods[i].Method, CheckID, 0, details);
					}
				}
			}
		}
예제 #22
0
        public void VisitFini(EndTesting end)
        {
            Unused.Value = end;

            if (m_needsCheck)
            {
                List <string> fields = new List <string>();

                foreach (KeyValuePair <FieldReference, State> entry in m_fields)
                {
                    if (entry.Value == State.Defined)
                    {
                        fields.Add(entry.Key.ToString());
                    }
                }

                if (fields.Count > 0)
                {
                    string details = "Fields: " + string.Join(Environment.NewLine, fields.ToArray());
                    Log.DebugLine(this, details);
                    Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
                }
            }
        }
예제 #23
0
		public void VisitEnd(EndTesting end)
		{			
			Unused.Value = end;
			
			if (m_downloader.Complete)
			{
				string[] parts = m_downloader.Contents.Trim().Split('.');
				int newMajor, newMinor;
				
				if (parts.Length == 2 && int.TryParse(parts[0], out newMajor) && int.TryParse(parts[1], out newMinor))
				{
					Version installed = Assembly.GetExecutingAssembly().GetName().Version;
	
					if (newMajor > installed.Major || (newMajor == installed.Major && newMinor > installed.Minor))
					{
						string details = string.Empty;
						details += "Latest Version:    " + m_downloader.Contents + Environment.NewLine;
						details += "Installed Version: " + installed.Major + "." + installed.Minor;
						Log.DebugLine(this, details);
						
						Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
					}
					else
					{
						Log.DebugLine(this, "installed version is OK");		
						Log.DebugLine(this, "installed: {0}", installed);		
						Log.DebugLine(this, "latest: {0}.{1}", newMajor, newMinor);		
					}
				}
				else
				{
					Log.ErrorLine(this, "Bad download: '{0}'", m_downloader.Contents);		
				}
			}
			else
			{
				TimeSpan duration = DateTime.Now - m_startTime;
				Log.WarningLine(this, "NewVersionRule wasn't able to download the version number within {0:0.000} seconds", duration.TotalSeconds);		

				m_downloader.Cancel();
			}
		}		
예제 #24
0
		public void VisitFini(EndTesting end)
		{
			Unused.Value = end;
			
			if (m_needsCheck)
			{
				List<string> fields = new List<string>();
				
				foreach (KeyValuePair<FieldReference, State> entry in m_fields)
				{
					if (entry.Value == State.Defined)
						fields.Add(entry.Key.ToString());
				}
				
				if (fields.Count > 0)
				{
					string details = "Fields: " + string.Join(Environment.NewLine, fields.ToArray());
					Log.DebugLine(this, details);
					Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
				}
			}
		}
예제 #25
0
 internal void Dispatch(EndTesting x)
 {
     DoVisit(x);
 }
예제 #26
0
		public void VisitFini(EndTesting end)
		{
			Unused.Value = end;
			
			if (m_bad.Count > 0)
			{
				string details = "Bad Calls: " + string.Join(Environment.NewLine, m_bad.ToArray());
				Log.DebugLine(this, details);
				
				Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
			}
		}
예제 #27
0
		// This is visited after methods.
		public void VisitFini(EndTesting end)
		{
			Unused.Value = end;
			
			DBC.Assert(m_state == State.Calls, "state is {0}", m_state);
			m_state = State.End;

			if (m_types.Count > 0)
			{
				string details = "Unused: " + string.Join(Environment.NewLine, m_types.ToArray());
				Log.DebugLine(this, details);

				Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
			}
		}
예제 #28
0
		public void VisitFini(EndTesting end)
		{
			Unused.Value = end;
			
			if (m_details.Length > 0)
			{
				m_details = "Asserting: " + m_details;
				Reporter.AssemblyFailed(Cache.Assembly, CheckID, m_details);
			}
		}
예제 #29
0
		public void VisitFini(EndTesting end)
		{
			Unused.Value = end;
			
			Dictionary<TypeDefinition, List<string>> bad = new Dictionary<TypeDefinition, List<string>>();
			List<TypeDefinition> hasCalls = new List<TypeDefinition>();
		
			foreach (KeyValuePair<MethodReference, Info> entry in m_candidates)
			{
				// We have a violation if a candidate method is only
				// called by its declaring type or a subclass (if it's not called at
				// all we'll let the UnusedMethod rule handle it).
				if (entry.Value.CalledBy != null)
				{
					if (entry.Value.CalledBy == entry.Value.Defined || entry.Value.CalledBy.IsSubclassOf(entry.Value.Defined, Cache))
					{
						List<string> methods;
						
						if (!bad.TryGetValue(entry.Value.Defined, out methods))
						{
							methods = new List<string>();
							bad.Add(entry.Value.Defined, methods);
						}
						
						methods.Add(entry.Key.ToString());
					}
					else
						hasCalls.Add(entry.Value.Defined);
				}
			}
			
			foreach (KeyValuePair<TypeDefinition, List<string>> entry2 in bad)
			{
				if (hasCalls.IndexOf(entry2.Key) < 0)
				{
					string details = "Methods: " + string.Join(Environment.NewLine, entry2.Value.ToArray());
					Log.DebugLine(this, details);	
					Reporter.TypeFailed(entry2.Key, CheckID, details);
				}
			}			
		}
예제 #30
0
		public void VisitFini(EndTesting end)
		{			
			Unused.Value = end;
			
			foreach (KeyValuePair<MethodDefinition, Entry> entry in m_table)
			{
				if (!entry.Value.CallsUri)
				{
					string details = "Method: " + entry.Key.Name;
					Log.DebugLine(this, details);
					
					TypeDefinition type = Cache.FindType(entry.Key.DeclaringType);
					Reporter.TypeFailed(type, CheckID, details);
				}
			}
		}
예제 #31
0
		public void VisitFini(EndTesting end)
		{		
			Unused.Value = end;
			
			List<string> bad = new List<string>();
			DoGetMatches(bad, m_namespaces, "Namespaces: ");
			DoGetMatches(bad, m_types, "Types: ");
			
			if (bad.Count > 0)
			{
				string details = string.Join(Environment.NewLine, bad.ToArray());
				Log.DebugLine(this, details);
				Reporter.AssemblyFailed(Cache.Assembly, CheckID, details);
			}
		}
예제 #32
0
		public void VisitFini(EndTesting end)
		{
			Unused.Value = end;
			
			foreach (KeyValuePair<TypeReference, List<TypeReference>> entry in m_table)
			{
				TypeReference type = entry.Key;
				string details = string.Empty;
				foreach (TypeReference r in entry.Value)
				{
					if (string.Compare(type.FullName, r.FullName) < 0)	// tie-breaker which prevents us from reporting the same error twice
					{
						List<TypeReference> refs = null;
						if (m_table.TryGetValue(r, out refs) && refs.IndexOf(type) >= 0)
						{
							details = string.Format("{0}{1} ", details, r);
						}
					}
				}
				
				if (details.Length > 0)
				{
					details = string.Format("{0} <-> {1} ", type.FullName, details);
					Log.DebugLine(this, details); 
		
					TypeDefinition t = Cache.FindType(type);
					if (t != null)
						Reporter.TypeFailed(t, CheckID, details);
				}
			}
		}