public void CustomPropertiesAreSet()
        {
            string[] properties =
            {
                "property #0",
                "property #1"
            };
            var issue = new ProjectIssue(s_Descriptor, "dummy issue", IssueCategory.Code);

            issue.SetCustomProperties(properties);

            Assert.True(issue.GetCustomProperty(0).Equals(properties[0]));
            Assert.True(issue.GetCustomProperty(1).Equals(properties[1]));
        }
        public static string GetProperty(this ProjectIssue issue, PropertyType propertyType)
        {
            switch (propertyType)
            {
            case PropertyType.Severity:
                return(issue.severity.ToString());

            case PropertyType.Area:
                return(issue.descriptor.area);

            case PropertyType.FileType:
                var ext = issue.location.Extension;
                if (ext.StartsWith("."))
                {
                    ext = ext.Substring(1);
                }
                return(ext);

            case PropertyType.Description:
                return(issue.description);

            case PropertyType.Filename:
                var filename = string.Format("{0}", issue.filename);
                if (string.IsNullOrEmpty(filename))
                {
                    return(k_NotAvailable);
                }
                if (filename.EndsWith(".cs"))
                {
                    filename += string.Format(":{0}", issue.line);
                }
                return(filename);

            case PropertyType.Path:
                var path = string.Format("{0}", issue.relativePath);
                if (string.IsNullOrEmpty(path))
                {
                    return(k_NotAvailable);
                }
                if (path.EndsWith(".cs"))
                {
                    path += string.Format(":{0}", issue.line);
                }
                return(path);

            case PropertyType.CriticalContext:
                return(issue.isPerfCriticalContext.ToString());

            default:
                var propertyIndex = propertyType - PropertyType.Num;
                return(issue.GetCustomProperty(propertyIndex));
            }
        }
Ejemplo n.º 3
0
        public bool Match(ProjectIssue issue)
        {
            // return false if the issue does not match one of these criteria:
            // - assembly name, if applicable
            // - area
            // - is not muted, if enabled
            // - critical context, if enabled/applicable

            Profiler.BeginSample("MatchAssembly");
            var matchAssembly = !activeView.desc.showAssemblySelection ||
                                m_AssemblySelection != null &&
                                (m_AssemblySelection.Contains(issue.GetCustomProperty((int)CodeProperty.Assembly)) ||
                                 m_AssemblySelection.ContainsGroup("All"));

            Profiler.EndSample();
            if (!matchAssembly)
            {
                return(false);
            }

            Profiler.BeginSample("MatchArea");
            var matchArea = !activeView.desc.showAreaSelection ||
                            m_AreaSelection.ContainsAny(issue.descriptor.area.Split('|')) ||
                            m_AreaSelection.ContainsGroup("All");

            Profiler.EndSample();
            if (!matchArea)
            {
                return(false);
            }

            if (!m_Preferences.mutedIssues && activeView.desc.showMuteOptions)
            {
                Profiler.BeginSample("IsMuted");
                var muted = m_ProjectAuditor.config.GetAction(issue.descriptor, issue.GetCallingMethod()) ==
                            Rule.Severity.None;
                Profiler.EndSample();
                if (muted)
                {
                    return(false);
                }
            }

            if (activeView.desc.showCritical &&
                m_Preferences.onlyCriticalIssues &&
                !issue.isPerfCriticalContext)
            {
                return(false);
            }

            return(m_TextFilter.Match(issue));
        }