public bool Match(ProjectIssue issue) { if (string.IsNullOrEmpty(searchText)) { return(true); } // return true if the issue matches the any of the following string search criteria if (MatchesSearch(issue.description)) { return(true); } if (MatchesSearch(issue.filename)) { return(true); } var dependencies = issue.dependencies; if (dependencies != null) { if (MatchesSearch(dependencies, searchDependencies)) { return(true); } } // no string match return(false); }
bool ShouldDisplay(ProjectIssue issue) { string url = issue.url; if (!m_EnablePackages && issue.category == IssueCategory.ApiCalls && (url.Contains("Library/PackageCache/") || url.Contains("Resources/PackageManager/BuiltInPackages/"))) { return(false); } // temporarily disabled Resolve Items button since there might be issues that have just been checked but are still shown in the list // if (!m_EnableResolvedItems && issue.resolved == true) // return false; string area = issue.descriptor.area; for (int index = 0; index < Enum.GetValues(typeof(Area)).Length; index++) { if (m_EnableAreas[index] && area.Contains(AreaEnumStrings[index])) { return(true); } } return(false); }
public bool ShouldDisplay(ProjectIssue issue) { if (m_ActiveMode == IssueCategory.ApiCalls && !m_AssemblySelection.Contains(issue.assembly) && !m_AssemblySelection.ContainsGroup("All")) { return(false); } if (!m_AreaSelection.Contains(issue.descriptor.area) && !m_AreaSelection.ContainsGroup("All")) { return(false); } if (!m_ProjectAuditor.config.displayMutedIssues) { if (m_ProjectAuditor.config.GetAction(issue.descriptor, issue.callingMethod) == Rule.Action.None) { return(false); } } if (!string.IsNullOrEmpty(m_SearchText)) { if (!MatchesSearch(issue.description) && !MatchesSearch(issue.filename) && !MatchesSearch(issue.name)) { return(false); } } return(true); }
public bool Match(ProjectIssue issue) { UnityEngine.Profiling.Profiler.BeginSample("MatchAssembly"); var matchAssembly = !m_ActiveAnalysisView.desc.showAssemblySelection || m_AssemblySelection != null && (m_AssemblySelection.Contains(issue.assembly) || m_AssemblySelection.ContainsGroup("All")); UnityEngine.Profiling.Profiler.EndSample(); if (!matchAssembly) { return(false); } UnityEngine.Profiling.Profiler.BeginSample("MatchArea"); var matchArea = m_AreaSelection.Contains(issue.descriptor.area) || m_AreaSelection.ContainsGroup("All"); UnityEngine.Profiling.Profiler.EndSample(); if (!matchArea) { return(false); } if (!m_ProjectAuditor.config.displayMutedIssues) { UnityEngine.Profiling.Profiler.BeginSample("IsMuted"); var muted = m_ProjectAuditor.config.GetAction(issue.descriptor, issue.callingMethod) == Rule.Action.None; UnityEngine.Profiling.Profiler.EndSample(); if (muted) { return(false); } } if (m_ActiveAnalysisView.desc.showCritical && m_ProjectAuditor.config.displayOnlyCriticalIssues && !issue.isPerfCriticalContext) { return(false); } if (!string.IsNullOrEmpty(m_SearchText)) { if (!MatchesSearch(issue.description) && !MatchesSearch(issue.filename) && !MatchesSearch(issue.name)) { return(false); } } return(true); }
internal static string FormatIssueForCSV(ProjectIssue issue) { if (issue.category == IssueCategory.Code) { return(string.Format("{0},\"{1}\",\"{2}\",{3},{4}:{5}", issue.category, issue.descriptor.description, issue.description, issue.descriptor.area, issue.relativePath, issue.line)); } return(string.Format("{0},\"{1}\",\"{2}\",{3},{4}", issue.category, issue.descriptor.description, issue.description, issue.descriptor.area, issue.relativePath)); }
private void DrawCallTree(ProjectIssue issue) { EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.Width(m_FoldoutWidth)); m_ShowCallTree = BoldFoldout(m_ShowCallTree, Styles.CallTreeFoldout); if (m_ShowCallTree) { if (issue != null) { // display method name without return type EditorGUILayout.LabelField(issue.callingMethod.Substring(issue.callingMethod.IndexOf(" "))); } else { EditorGUILayout.LabelField(NoIssueSelectedText); } } EditorGUILayout.EndVertical(); }
private void AnalyzeAssembly(string assemblyPath, ProjectReport projectReport) { using (var a = AssemblyDefinition.ReadAssembly(assemblyPath, new ReaderParameters() { ReadSymbols = true })) { foreach (var m in a.MainModule.Types.SelectMany(t => t.Methods)) { if (!m.HasBody) { continue; } List <ProjectIssue> methodBobyIssues = new List <ProjectIssue>(); foreach (var inst in m.Body.Instructions.Where(i => (i.OpCode == OpCodes.Call || i.OpCode == OpCodes.Callvirt))) { var calledMethod = ((MethodReference)inst.Operand); // HACK: need to figure out a way to know whether a method is actually a property var p = m_ProblemDescriptors.SingleOrDefault(c => c.type == calledMethod.DeclaringType.FullName && (c.method == calledMethod.Name || ("get_" + c.method) == calledMethod.Name)); if (p == null) { // Are we trying to warn about a whole namespace? p = m_ProblemDescriptors.SingleOrDefault(c => c.type == calledMethod.DeclaringType.Namespace && c.method == "*"); } //if (p.type != null && m.HasCustomDebugInformations) if (p != null && m.DebugInformation.HasSequencePoints) { //var msg = string.Empty; SequencePoint s = null; for (var i = inst; i != null; i = i.Previous) { s = m.DebugInformation.GetSequencePoint(i); if (s != null) { // msg = i == inst ? " exactly" : "nearby"; break; } } if (s != null) { // Ignore whitelisted packages // (SteveM - I'd put this code further up in one of the outer loops but I don't // know if it's possible to get the URL further up to compare with the whitelist) bool isPackageWhitelisted = false; foreach (string package in m_WhitelistedPackages) { if (s.Document.Url.Contains(package)) { isPackageWhitelisted = true; break; } } if (!isPackageWhitelisted) { var description = p.description; if (description.Contains(".*")) { description = calledMethod.DeclaringType.FullName + "::" + calledMethod.Name; } // do not add the same type of issue again (for example multiple Linq instructions) var foundIssues = methodBobyIssues.Where(i => i.descriptor == p && i.line == s.StartLine && i.column == s.StartColumn); if (foundIssues.FirstOrDefault() == null) { var projectIssue = new ProjectIssue { description = description, category = IssueCategory.ApiCalls, descriptor = p, callingMethod = m.FullName, url = s.Document.Url.Replace("\\", "/"), line = s.StartLine, column = s.StartColumn }; projectReport.AddIssue(projectIssue); methodBobyIssues.Add(projectIssue); } } } } } } } }
public void AddIssue(ProjectIssue projectIssue) { mutex.WaitOne(); m_Issues.Add(projectIssue); mutex.ReleaseMutex(); }
public IssueTableItem(int id, int depth, string displayName, ProblemDescriptor problemDescriptor, ProjectIssue projectIssue = null) : base(id, depth, displayName) { this.problemDescriptor = problemDescriptor; m_ProjectIssue = projectIssue; }
public void AddIssue(ProjectIssue projectIssue) { m_IssueDict[projectIssue.category].Add(projectIssue); }
internal void AddIssue(ProjectIssue projectIssue) { s_Mutex.WaitOne(); m_Issues.Add(projectIssue); s_Mutex.ReleaseMutex(); }
public void AddIssue(ProjectIssue projectIssue) { m_Issues.Add(projectIssue); }