Esempio n. 1
0
        public override void MessageHandler(object sender, BuildMessageEventArgs e)
        {
            LoggerVerbosity minimumVerbosity = ImportanceToMinimumVerbosity(e.Importance, out bool lightenText);
            bool            print            = IsVerbosityAtLeast(minimumVerbosity);

            if (print)
            {
                ShowDeferredMessages();

                if (lightenText)
                {
                    setColor(ConsoleColor.DarkGray);
                }

                string nonNullMessage;

                // Include file information if present.
                if (e.File != null)
                {
                    nonNullMessage = EventArgsFormatting.FormatEventMessage(e, showProjectFile);
                }
                else
                {
                    // null messages are ok -- treat as blank line
                    nonNullMessage = e.Message ?? String.Empty;
                }

                WriteLinePretty(nonNullMessage);

                if (lightenText)
                {
                    resetColor();
                }
            }
        }
Esempio n. 2
0
 public void NullMessage()
 {
     // Testing the method in Shared.EventArgsFormatting directly
     string s = EventArgsFormatting.FormatEventMessage("error", "CS",
                                                       null, "312", "source.cs", 233, 236, 4, 8, 0);
     // No exception was thrown
 }
Esempio n. 3
0
        /// <summary>
        /// Prints a warning event
        /// </summary>
        public override void WarningHandler(object sender, BuildWarningEventArgs e)
        {
            warningCount++;
            SetErrorsOrWarningsOnCurrentFrame();
            ShowDeferredMessages();
            setColor(ConsoleColor.Yellow);

            //determine the mapping of properties to output
            Dictionary <string, string> outputProperties = new Dictionary <string, string>();

            if (e.BuildEventContext != null)
            {
                int nodeId           = e.BuildEventContext.NodeId;
                int projectContextId = e.BuildEventContext.ProjectContextId;
                TargetFramework_mapping.TryGetValue((nodeId, projectContextId), out outputProperties);
            }
            e.outputProperties = outputProperties;

            WriteLinePretty(EventArgsFormatting.FormatEventMessage(e, showProjectFile));
            if (ShowSummary == true)
            {
                warningList.Add(e);
            }
            resetColor();
        }
        /// <summary>
        /// At the end of the build, repeats the errors and warnings that occurred
        /// during the build, and displays the error count and warning count.
        /// </summary>
        private void ShowErrorWarningSummary()
        {
            if (warningCount == 0 && errorCount == 0)
            {
                return;
            }

            // Make some effort to distinguish the summary from the previous output
            WriteNewLine();

            if (warningCount > 0)
            {
                setColor(ConsoleColor.Yellow);
                foreach (BuildWarningEventArgs warningEventArgs in warningList)
                {
                    WriteLinePretty(EventArgsFormatting.FormatEventMessage(warningEventArgs, runningWithCharacterFileType, showProjectFile));
                }
            }

            if (errorCount > 0)
            {
                setColor(ConsoleColor.Red);
                foreach (BuildErrorEventArgs errorEventArgs in errorList)
                {
                    WriteLinePretty(EventArgsFormatting.FormatEventMessage(errorEventArgs, runningWithCharacterFileType, showProjectFile));
                }
            }

            resetColor();
        }
Esempio n. 5
0
        public void LineAndColumnNumberRange5()
        {
            string s = EventArgsFormatting.FormatEventMessage("error", "CS",
                                                              "Missing ;", "312", "source.cs", 1, 0, 2, 0, 0);

            s.ShouldBe("source.cs(1,2): CS error 312: Missing ;");
        }
Esempio n. 6
0
        /// <summary>
        /// Given a resource string and information about a file, builds up a string
        /// containing the message.
        /// </summary>
        private static string BuildStringFromResource
        (
            string projectFile,
            int fileLine,
            int fileEndLine,
            int fileColumn,
            int fileEndColumn,
            string resourceName,
            params object[] args
        )
        {
            string errorCode;
            string helpKeyword;
            string message = ResourceUtilities.FormatResourceString(out errorCode, out helpKeyword, resourceName, args);

            return(EventArgsFormatting.FormatEventMessage
                   (
                       "error",
                       AssemblyResources.GetString("SubCategoryForSchemaValidationErrors"),
                       message,
                       errorCode,
                       projectFile,
                       fileLine,
                       fileEndLine,
                       fileColumn,
                       fileEndColumn,
                       0 /* thread id */
                   ));
        }
Esempio n. 7
0
        public void ExactLocationFormatEventMessage()
        {
            // Testing the method in Shared.EventArgsFormatting directly
            string s = EventArgsFormatting.FormatEventMessage("error", "CS",
                                                              "Missing ;", "312", "source.cs", 233, 236, 4, 8, 0);

            s.ShouldBe("source.cs(233,4,236,8): CS error 312: Missing ;");
        }
Esempio n. 8
0
        public void LineAndColumnNumberRange2()
        {
            string s = EventArgsFormatting.FormatEventMessage("error", "CS",
                                                              "Missing ;", "312", "source.cs", 1, 0, 3, 4, 0);

            Assertion.AssertEquals(
                "source.cs(1,3-4): CS error 312: Missing ;", s);
        }
Esempio n. 9
0
        public void ColumnNumberRange()
        {
            string s = EventArgsFormatting.FormatEventMessage("error", "CS",
                                                              "Missing ;", "312", "source.cs", 0, 0, 1, 2, 0);

            Assertion.AssertEquals(
                "source.cs : CS error 312: Missing ;", s);
        }
Esempio n. 10
0
        public void BasicFormatEventMessage()
        {
            // Testing the method in Shared.EventArgsFormatting directly
            string s = EventArgsFormatting.FormatEventMessage("error", "CS",
                                                              "Missing ;", "312", "source.cs", 42, 0, 0, 0, 0);

            s.ShouldBe("source.cs(42): CS error 312: Missing ;");
        }
Esempio n. 11
0
        public void LineAndColumnNumberRange4()
        {
            string s = EventArgsFormatting.FormatEventMessage("error", "CS",
                                                              "Missing ;", "312", "source.cs", 1, 2, 0, 3, 0);

            Assert.AreEqual(
                "source.cs(1-2): CS error 312: Missing ;", s);
        }
Esempio n. 12
0
        public void LogWarningEvent(BuildWarningEventArgs eventArgs)
        {
            Console.WriteLine(EventArgsFormatting.FormatEventMessage(eventArgs));
            _log += EventArgsFormatting.FormatEventMessage(eventArgs);
            ++_warnings;

            _log     += "\n";
            _upperLog = null;
        }
Esempio n. 13
0
        public void NoLineInfoFormatEventMessage()
        {
            // Testing the method in Shared.EventArgsFormatting directly
            string s = EventArgsFormatting.FormatEventMessage("error", "CS",
                                                              "Missing ;", "312", "source.cs", 0, 0, 0, 0, 0);

            Assert.AreEqual(
                "source.cs : CS error 312: Missing ;", s);
        }
Esempio n. 14
0
        public void LogErrorEvent(BuildErrorEventArgs eventArgs)
        {
            Console.WriteLine(EventArgsFormatting.FormatEventMessage(eventArgs));
            _log += EventArgsFormatting.FormatEventMessage(eventArgs);
            ++_errors;

            _log     += "\n";
            _upperLog = null;
        }
        /// <summary>
        /// Prints a message event
        /// </summary>
        public override void MessageHandler(object sender, BuildMessageEventArgs e)
        {
            bool print       = false;
            bool lightenText = false;

            switch (e.Importance)
            {
            case MessageImportance.High:
                print = IsVerbosityAtLeast(LoggerVerbosity.Minimal);
                break;

            case MessageImportance.Normal:
                print       = IsVerbosityAtLeast(LoggerVerbosity.Normal);
                lightenText = true;
                break;

            case MessageImportance.Low:
                print       = IsVerbosityAtLeast(LoggerVerbosity.Detailed);
                lightenText = true;
                break;

            default:
                ErrorUtilities.VerifyThrow(false, "Impossible");
                break;
            }

            if (print)
            {
                ShowDeferredMessages();

                if (lightenText)
                {
                    setColor(ConsoleColor.DarkGray);
                }

                string nonNullMessage = null;

                // Include file information if present.
                if (e.File != null)
                {
                    nonNullMessage = EventArgsFormatting.FormatEventMessage(e, runningWithCharacterFileType, showProjectFile);
                }
                else
                {
                    // null messages are ok -- treat as blank line
                    nonNullMessage = (e.Message == null) ? String.Empty : e.Message;
                }

                WriteLinePretty(nonNullMessage);

                if (lightenText)
                {
                    resetColor();
                }
            }
        }
Esempio n. 16
0
        public void CarriageReturnInMessageIsUnchanged()
        {
            BuildErrorEventArgs   error   = new BuildErrorEventArgs("CS", "312", "source.cs", 42, 0, 0, 0, "message\r Hello", "help", "sender");
            BuildWarningEventArgs warning = new BuildWarningEventArgs("CS", "312", "source.cs", 42, 0, 0, 0, "message\r Hello", "help", "sender");

            // Testing the method in Shared.EventArgsFormatting directly
            string errorString   = EventArgsFormatting.FormatEventMessage(error);
            string warningString = EventArgsFormatting.FormatEventMessage(warning);

            errorString.ShouldBe("source.cs(42): CS error 312: message\r Hello");
            warningString.ShouldBe("source.cs(42): CS warning 312: message\r Hello");
        }
 /// <summary>
 /// Prints a warning event
 /// </summary>
 public override void WarningHandler(object sender, BuildWarningEventArgs e)
 {
     warningCount++;
     SetErrorsOrWarningsOnCurrentFrame();
     ShowDeferredMessages();
     setColor(ConsoleColor.Yellow);
     WriteLinePretty(EventArgsFormatting.FormatEventMessage(e, runningWithCharacterFileType, showProjectFile));
     if (ShowSummary == true)
     {
         warningList.Add(e);
     }
     resetColor();
 }
Esempio n. 18
0
 public override void ErrorHandler(object sender, BuildErrorEventArgs e)
 {
     errorCount++;
     SetErrorsOrWarningsOnCurrentFrame();
     ShowDeferredMessages();
     setColor(ConsoleColor.Red);
     WriteLinePretty(EventArgsFormatting.FormatEventMessage(e, showProjectFile));
     if (ShowSummary == true)
     {
         errorList.Add(e);
     }
     resetColor();
 }
Esempio n. 19
0
        public void EscapeCarriageReturnMessages()
        {
            BuildErrorEventArgs   error   = new BuildErrorEventArgs("CS", "312", "source.cs", 42, 0, 0, 0, "message\r Hello", "help", "sender");
            BuildWarningEventArgs warning = new BuildWarningEventArgs("CS", "312", "source.cs", 42, 0, 0, 0, "message\r Hello", "help", "sender");
            // Testing the method in Shared.EventArgsFormatting directly
            string errorString    = EventArgsFormatting.FormatEventMessage(error, true);
            string warningString  = EventArgsFormatting.FormatEventMessage(warning, true);
            string errorString2   = EventArgsFormatting.FormatEventMessage(error, false);
            string warningString2 = EventArgsFormatting.FormatEventMessage(warning, false);

            Assert.AreEqual("source.cs(42): CS error 312: message\\r Hello", errorString);
            Assert.AreEqual("source.cs(42): CS warning 312: message\\r Hello", warningString);

            Assert.AreEqual("source.cs(42): CS error 312: message\r Hello", errorString2);
            Assert.AreEqual("source.cs(42): CS warning 312: message\r Hello", warningString2);
        }
Esempio n. 20
0
        /// <summary>
        /// Prints a message event
        /// </summary>
        public override void MessageHandler(object sender, BuildMessageEventArgs e)
        {
            //determine the mapping of properties to output
            Dictionary <string, string> outputProperties = new Dictionary <string, string>();

            if (e.BuildEventContext != null)
            {
                int nodeId           = e.BuildEventContext.NodeId;
                int projectContextId = e.BuildEventContext.ProjectContextId;
                TargetFramework_mapping.TryGetValue((nodeId, projectContextId), out outputProperties);
            }
            e.outputProperties = outputProperties;

            bool print       = false;
            bool lightenText = false;

            switch (e.Importance)
            {
            case MessageImportance.High:
                print = IsVerbosityAtLeast(LoggerVerbosity.Minimal);
                break;

            case MessageImportance.Normal:
                print       = IsVerbosityAtLeast(LoggerVerbosity.Normal);
                lightenText = true;
                break;

            case MessageImportance.Low:
                print       = IsVerbosityAtLeast(LoggerVerbosity.Detailed);
                lightenText = true;
                break;

            default:
                ErrorUtilities.VerifyThrow(false, "Impossible");
                break;
            }

            if (print)
            {
                ShowDeferredMessages();

                if (lightenText)
                {
                    setColor(ConsoleColor.DarkGray);
                }

                string nonNullMessage = null;

                // Include file information if present.
                if (e.File != null)
                {
                    nonNullMessage = EventArgsFormatting.FormatEventMessage(e, showProjectFile);
                }
                else
                {
                    // null messages are ok -- treat as blank line
                    nonNullMessage = (e.Message == null) ? String.Empty : e.Message;
                }

                WriteLinePretty(nonNullMessage);

                if (lightenText)
                {
                    resetColor();
                }
            }
        }
Esempio n. 21
0
 public void LogWarningEvent(BuildWarningEventArgs eventArgs)
 {
     Console.WriteLine(EventArgsFormatting.FormatEventMessage(eventArgs));
     _log.AppendLine(EventArgsFormatting.FormatEventMessage(eventArgs));
     ++Warnings;
 }
Esempio n. 22
0
 public void LogErrorEvent(BuildErrorEventArgs eventArgs)
 {
     Console.WriteLine(EventArgsFormatting.FormatEventMessage(eventArgs));
     _log.AppendLine(EventArgsFormatting.FormatEventMessage(eventArgs));
     ++Errors;
 }
Esempio n. 23
0
 /// <summary>
 /// Generates a message in the default format from a BuildErrorEventArgs object.
 /// </summary>
 /// <param name="args">Error event arguments</param>
 /// <returns>Error message in canonical format</returns>
 public virtual string FormatErrorEvent(BuildErrorEventArgs args) => EventArgsFormatting.FormatEventMessage(args);
Esempio n. 24
0
 /// <summary>
 /// Generates a message in the default format from a BuildWarningEventArgs object.
 /// </summary>
 /// <param name="args">Warning event arguments</param>
 /// <returns>Warning message in canonical format</returns>
 public virtual string FormatWarningEvent(BuildWarningEventArgs args) => EventArgsFormatting.FormatEventMessage(args);
Esempio n. 25
0
 public virtual string FormatWarningEvent(BuildWarningEventArgs args)
 {
     return(EventArgsFormatting.FormatEventMessage(args));
 }