static string Print(BuildErrorEventArgs e)
    {
        var props = e.GetType().GetProperties();
        var data  = props.Select(p => $"{p.Name}: {p.GetValue(e)}");

        return(string.Join(Environment.NewLine, data));
    }
Esempio n. 2
0
 public BuildMessage(BuildErrorEventArgs args)
 {
     EventType       = args.GetType().Name.Replace("EventArgs", "");
     Code            = args.Code;
     ColumnNumber    = args.ColumnNumber;
     EndColumnNumber = args.EndColumnNumber;
     EndLineNumber   = args.EndLineNumber;
     File            = args.File;
     LineNumber      = args.LineNumber;
     Message         = args.Message;
     ProjectFile     = args.ProjectFile;
     Subcategory     = args.Subcategory;
     HelpKeyword     = args.HelpKeyword;
     SenderName      = args.SenderName;
     Timestamp       = args.Timestamp;
     ThreadId        = args.ThreadId;
 }
Esempio n. 3
0
        /// <summary>
        /// Stub implementation -- forwards to engine being proxied.
        /// </summary>
        public void LogErrorEvent(BuildErrorEventArgs e)
        {
            ErrorUtilities.VerifyThrowArgumentNull(e, "e");
            ErrorUtilities.VerifyThrowInvalidOperation(activeProxy == true, "AttemptingToLogFromInactiveTask");

            if (parentModule.IsRunningMultipleNodes && !e.GetType().IsSerializable)
            {
                loggingServices.LogWarning(buildEventContext, new BuildEventFileInfo(string.Empty), "ExpectedEventToBeSerializable", e.GetType().Name);
                return;
            }

            string message = GetUpdatedMessage(e.File, e.Message, parentProjectFullFileName);

            if (ContinueOnError)
            {
                // Convert the error into a warning.  We do this because the whole point of
                // ContinueOnError is that a project author expects that the task might fail,
                // but wants to ignore the failures.  This implies that we shouldn't be logging
                // errors either, because you should never have a successful build with errors.
                BuildWarningEventArgs warningEvent = new BuildWarningEventArgs
                                                         (e.Subcategory,
                                                         e.Code,
                                                         e.File,
                                                         e.LineNumber,
                                                         e.ColumnNumber,
                                                         e.EndLineNumber,
                                                         e.EndColumnNumber,
                                                         message, // this is the new message from above
                                                         e.HelpKeyword,
                                                         e.SenderName);

                warningEvent.BuildEventContext = buildEventContext;
                loggingServices.LogWarningEvent(warningEvent);

                // Log a message explaining why we converted the previous error into a warning.
                loggingServices.LogComment(buildEventContext, MessageImportance.Normal, "ErrorConvertedIntoWarning");
            }
            else
            {
                if (e.GetType().Equals(BuildErrorEventArgsType))
                {
                    // We'd like to add the project file to the subcategory, but since this property
                    // is read-only on the BuildErrorEventArgs type, this requires creating a new
                    // instance.  However, if some task logged a custom error type, we don't want to
                    // impolitely (as we already do above on ContinueOnError) throw the custom type
                    // data away.
                    e = new BuildErrorEventArgs
                        (
                        e.Subcategory,
                        e.Code,
                        e.File,
                        e.LineNumber,
                        e.ColumnNumber,
                        e.EndLineNumber,
                        e.EndColumnNumber,
                        message,      // this is the new message from above
                        e.HelpKeyword,
                        e.SenderName
                        );
                }

                e.BuildEventContext = buildEventContext;
                loggingServices.LogErrorEvent(e);
            }
        }