コード例 #1
0
            public static Highlight TryCreate(OutputHighlight highlight, IContentType contentType)
            {
                Highlight result = null;

                // We shouldn't encounter an empty pattern, but we'll check for it anyway
                // since we can't really highlight empty lines.
                if (!string.IsNullOrEmpty(highlight.Pattern))
                {
                    // We don't need to validate against OutputClassifierProvider.GetOutputContentTypes() here.
                    // The OutputHighlight class already tries to do that.  Here we're passed a known valid type,
                    // and we just need to see if it's in the OutputHighlight's pre-verified list.
                    if (highlight.ContentTypes.Any(ct => Utilities.IsContentOfType(contentType, ct)))
                    {
                        Regex pattern = new Regex(highlight.Pattern, highlight.MatchCase ? RegexOptions.None : RegexOptions.IgnoreCase);
                        result = new Highlight()
                        {
                            HighlightType = highlight.Highlight,
                            Pattern       = pattern
                        };
                    }
                }

                return(result);
            }
コード例 #2
0
        private static List <OutputHighlight> CreateDefaultOutputHighlights()
        {
            List <OutputHighlight> result = new();

            ISet <string> knownOutputContentTypes = OutputHighlight.GetKnownOutputContentTypes();

            string[] buildContent = OutputHighlight.ValidateContentTypes(new[] { "BuildOutput", "BuildOrderOutput" }, knownOutputContentTypes);
            if (buildContent.Length > 0)
            {
                result.Add(new OutputHighlight("Code Analysis Success", OutputHighlightType.None, @"\s0 error\(s\), 0 warning\(s\)$", buildContent));
            }

            // The "Ext: ExceptionBreaker (Diagnostic)" pane uses a general Output content type.
            // We have to match this before the normal "exception:" rule.
            result.Add(new OutputHighlight(
                           "Previous/Conflicting Exception",
                           OutputHighlightType.None,
                           @"^\s*(Previous|Conflicting) exception:")
            {
                MatchCase = true
            });

            string[] debugContent = OutputHighlight.ValidateContentTypes(new[] { "DebugOutput" }, knownOutputContentTypes);
            if (debugContent.Length > 0)
            {
                result.Add(new OutputHighlight("Exception", OutputHighlightType.Error, @"(exception:|stack trace:)", debugContent));
                result.Add(new OutputHighlight("Exception At", OutputHighlightType.Error, @"^\s+at\s", debugContent));
            }

            string[] testsContent = OutputHighlight.ValidateContentTypes(new[] { "TestsOutput" }, knownOutputContentTypes);
            if (testsContent.Length > 0)
            {
                result.Add(new OutputHighlight("Test Host Abort", OutputHighlightType.Error, @"^The active (\w+\s)+was aborted\s", testsContent));
                result.Add(new OutputHighlight("Test Host Exception", OutputHighlightType.Error, @"\wException:\s", testsContent)
                {
                    MatchCase = true
                });
            }

            string[] tfsContent = OutputHighlight.ValidateContentTypes(new[] { "TFSourceControlOutput" }, knownOutputContentTypes);
            if (tfsContent.Length > 0)
            {
                result.Add(new OutputHighlight("TFS Error Code", OutputHighlightType.Error, @"^TF\d+\:\s", tfsContent));
                result.Add(new OutputHighlight("TFS Unable To Get", OutputHighlightType.Warning, @"\WUnable to perform the get operation\W", tfsContent));
                result.Add(new OutputHighlight("TFS Newer Version", OutputHighlightType.Warning, @"(\W|^)newer version exists in source control$", tfsContent));
                result.Add(new OutputHighlight("TFS Auto Resolve", OutputHighlightType.Information, @"^Automatically resolved conflict\:\W", tfsContent));
                result.Add(new OutputHighlight("TFS Check In", OutputHighlightType.Information, @"^Changeset \d+ successfully checked in\.$", tfsContent));
                result.Add(new OutputHighlight("TFS Check Out", OutputHighlightType.Detail, @"\Whas been automatically checked out\W", tfsContent));
                result.Add(new OutputHighlight("TFS Open For Edit", OutputHighlightType.Detail, @"^\s*opened for edit in\s", tfsContent));
                result.Add(new OutputHighlight("TFS File Path", OutputHighlightType.Detail, @"^\$/.+\:$", tfsContent));
            }

            // These apply to all Output windows, so put them last.  The Header/Footer pattern has to come
            // before the Error pattern because builds use the word "failed" in the output footer.
            result.Add(new OutputHighlight("Header/Footer", OutputHighlightType.Header, @"------ |========== "));
            result.Add(new OutputHighlight("Exception cache is built", OutputHighlightType.None, @"^Exception cache is built\:"));
            result.Add(new OutputHighlight("Error", OutputHighlightType.Error, @"(\W|^)(error|fail|failed|exception)\W"));
            result.Add(new OutputHighlight("Warning", OutputHighlightType.Warning, @"(\W|^)warning\W"));
            result.Add(new OutputHighlight("Information", OutputHighlightType.Information, @"(\W|^)information\W"));

            return(result);
        }