* ConsoleLogger.cs: Keep track of all the errors and warnings
authorAnkit Jain <radical@corewars.org>
Thu, 30 Jul 2009 21:24:40 +0000 (21:24 -0000)
committerAnkit Jain <radical@corewars.org>
Thu, 30 Jul 2009 21:24:40 +0000 (21:24 -0000)
and show them at the end.

svn path=/trunk/mcs/; revision=139127

mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs

index 9ae6324919b1eb8442a987c74b4be04a36c4adfc..476085ab2b3cb0ae96b2adbd0dbfad762a947f1b 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-31  Ankit Jain  <jankit@novell.com>
+
+       * ConsoleLogger.cs: Keep track of all the errors and warnings
+       and show them at the end.
+
 2009-07-31  Ankit Jain  <jankit@novell.com>
 
        * Target.cs (Build): Log a message if a target is skipped.
index 205b2ee045bd0613162e5f5bad1763abc08094bd..d1919c0c72e8f5061e246e254d595e1f7b2595a3 100644 (file)
@@ -29,6 +29,7 @@
 
 using System;
 using System.Runtime.InteropServices;
+using System.Collections.Generic;
 using System.IO;
 using System.Security;
 using Microsoft.Build.Framework;
@@ -46,6 +47,7 @@ namespace Microsoft.Build.BuildEngine {
                bool            performanceSummary;
                bool            showSummary;
                bool            skipProjectStartedText;
+               List<string> errors, warnings;
                
                public ConsoleLogger ()
                        : this (LoggerVerbosity.Normal, null, null, null)
@@ -74,6 +76,8 @@ namespace Microsoft.Build.BuildEngine {
                        this.performanceSummary = false;
                        this.showSummary = true;
                        this.skipProjectStartedText = false;
+                       errors = new List<string> ();
+                       warnings = new List<string> ();
                }
                
                public void ApplyParameter (string parameterName,
@@ -115,6 +119,19 @@ namespace Microsoft.Build.BuildEngine {
                        }
                        if (performanceSummary == true) {
                        }
+
+                       if (errors.Count > 0) {
+                               WriteLine ("Errors:");
+                               foreach (string error in errors)
+                                       WriteLine (error);
+                       }
+
+                       if (warnings.Count > 0) {
+                               WriteLine ("Warnings:");
+                               foreach (string warning in warnings)
+                                       WriteLine (warning);
+                       }
+
                        if (showSummary == true){
                                TimeSpan timeElapsed = args.Timestamp - buildStart;
                                WriteLine (String.Format ("\t {0} Warning(s)", warningCount));
@@ -186,15 +203,19 @@ namespace Microsoft.Build.BuildEngine {
                
                public void WarningHandler (object sender, BuildWarningEventArgs args)
                {
-                       if (IsVerbosityGreaterOrEqual (LoggerVerbosity.Normal)) 
-                               WriteLineWithoutIndent (FormatWarningEvent (args));
+                       string msg = FormatWarningEvent (args);
+                       if (IsVerbosityGreaterOrEqual (LoggerVerbosity.Normal))
+                               WriteLineWithoutIndent (msg);
+                       warnings.Add (msg);
                        warningCount++;
                }
                
                public void ErrorHandler (object sender, BuildErrorEventArgs args)
                {
+                       string msg = FormatErrorEvent (args);
                        if (IsVerbosityGreaterOrEqual (LoggerVerbosity.Minimal)) 
-                               WriteLineWithoutIndent (FormatErrorEvent (args));
+                               WriteLineWithoutIndent (msg);
+                       errors.Add (msg);
                        errorCount++;
                }
                
@@ -245,10 +266,10 @@ namespace Microsoft.Build.BuildEngine {
                {
                        // FIXME: show more complicated args
                        if (args.LineNumber != 0 && args.ColumnNumber != 0) {
-                               return String.Format ("{0}({1},{2}): {3} error {4}: {5}", args.File, args.LineNumber, args.ColumnNumber,
+                               return String.Format ("{0}({1},{2}): {3} Error {4}: {5}", args.File, args.LineNumber, args.ColumnNumber,
                                        args.Subcategory, args.Code, args.Message);
                        } else {
-                               return String.Format ("{0}: {1} error {2}: {3}", args.File, args.Subcategory, args.Code,
+                               return String.Format ("{0}: {1} Error {2}: {3}", args.File, args.Subcategory, args.Code,
                                        args.Message);
                        }
                }
@@ -257,10 +278,10 @@ namespace Microsoft.Build.BuildEngine {
                {
                        // FIXME: show more complicated args
                        if (args.LineNumber != 0 && args.ColumnNumber != 0) {
-                               return String.Format ("{0}({1},{2}): {3} warning {4}: {5}", args.File, args.LineNumber, args.ColumnNumber,
+                               return String.Format ("{0}({1},{2}): {3} Warning {4}: {5}", args.File, args.LineNumber, args.ColumnNumber,
                                        args.Subcategory, args.Code, args.Message);
                        } else {
-                               return String.Format ("{0}: {1} warning {2}: {3}", args.File, args.Subcategory, args.Code,
+                               return String.Format ("{0}: {1} Warning {2}: {3}", args.File, args.Subcategory, args.Code,
                                        args.Message);
                        }
                }