Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 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));
 }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        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);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
 public void AddIssue(ProjectIssue projectIssue)
 {
     mutex.WaitOne();
     m_Issues.Add(projectIssue);
     mutex.ReleaseMutex();
 }
Ejemplo n.º 9
0
 public IssueTableItem(int id, int depth, string displayName, ProblemDescriptor problemDescriptor, ProjectIssue projectIssue = null) : base(id, depth, displayName)
 {
     this.problemDescriptor = problemDescriptor;
     m_ProjectIssue         = projectIssue;
 }
Ejemplo n.º 10
0
 public void AddIssue(ProjectIssue projectIssue)
 {
     m_IssueDict[projectIssue.category].Add(projectIssue);
 }
Ejemplo n.º 11
0
 internal void AddIssue(ProjectIssue projectIssue)
 {
     s_Mutex.WaitOne();
     m_Issues.Add(projectIssue);
     s_Mutex.ReleaseMutex();
 }
Ejemplo n.º 12
0
 public void AddIssue(ProjectIssue projectIssue)
 {
     m_Issues.Add(projectIssue);
 }