Skip to content

Commit

Permalink
Merge pull request #43028 from neikeq/rework-csharp-build-panel
Browse files Browse the repository at this point in the history
C#: Re-work solution build output panel
  • Loading branch information
akien-mga authored Oct 23, 2020
2 parents 32be929 + f06f912 commit d5073c6
Show file tree
Hide file tree
Showing 11 changed files with 499 additions and 526 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public class GodotBuildLogger : ILogger
public void Initialize(IEventSource eventSource)
{
if (null == Parameters)
throw new LoggerException("Log directory was not set.");
throw new LoggerException("Log directory parameter not specified.");

var parameters = Parameters.Split(new[] { ';' });

string logDir = parameters[0];

if (string.IsNullOrEmpty(logDir))
throw new LoggerException("Log directory was not set.");
throw new LoggerException("Log directory parameter is empty.");

if (parameters.Length > 1)
throw new LoggerException("Too many parameters passed.");
Expand Down Expand Up @@ -51,22 +51,31 @@ public void Initialize(IEventSource eventSource)
{
throw new LoggerException("Failed to create log file: " + ex.Message);
}
else
{
// Unexpected failure
throw;
}

// Unexpected failure
throw;
}

eventSource.ProjectStarted += eventSource_ProjectStarted;
eventSource.TaskStarted += eventSource_TaskStarted;
eventSource.ProjectFinished += eventSource_ProjectFinished;
eventSource.MessageRaised += eventSource_MessageRaised;
eventSource.WarningRaised += eventSource_WarningRaised;
eventSource.ErrorRaised += eventSource_ErrorRaised;
eventSource.ProjectFinished += eventSource_ProjectFinished;
}

void eventSource_ErrorRaised(object sender, BuildErrorEventArgs e)
private void eventSource_ProjectStarted(object sender, ProjectStartedEventArgs e)
{
WriteLine(e.Message);
indent++;
}

private void eventSource_ProjectFinished(object sender, ProjectFinishedEventArgs e)
{
indent--;
WriteLine(e.Message);
}

private void eventSource_ErrorRaised(object sender, BuildErrorEventArgs e)
{
string line = $"{e.File}({e.LineNumber},{e.ColumnNumber}): error {e.Code}: {e.Message}";

Expand All @@ -81,7 +90,7 @@ void eventSource_ErrorRaised(object sender, BuildErrorEventArgs e)
issuesStreamWriter.WriteLine(errorLine);
}

void eventSource_WarningRaised(object sender, BuildWarningEventArgs e)
private void eventSource_WarningRaised(object sender, BuildWarningEventArgs e)
{
string line = $"{e.File}({e.LineNumber},{e.ColumnNumber}): warning {e.Code}: {e.Message}";

Expand All @@ -108,40 +117,6 @@ private void eventSource_MessageRaised(object sender, BuildMessageEventArgs e)
}
}

private void eventSource_TaskStarted(object sender, TaskStartedEventArgs e)
{
// TaskStartedEventArgs adds ProjectFile, TaskFile, TaskName
// To keep this log clean, this logger will ignore these events.
}

private void eventSource_ProjectStarted(object sender, ProjectStartedEventArgs e)
{
WriteLine(e.Message);
indent++;
}

private void eventSource_ProjectFinished(object sender, ProjectFinishedEventArgs e)
{
indent--;
WriteLine(e.Message);
}

/// <summary>
/// Write a line to the log, adding the SenderName
/// </summary>
private void WriteLineWithSender(string line, BuildEventArgs e)
{
if (0 == string.Compare(e.SenderName, "MSBuild", StringComparison.OrdinalIgnoreCase))
{
// Well, if the sender name is MSBuild, let's leave it out for prettiness
WriteLine(line);
}
else
{
WriteLine(e.SenderName + ": " + line);
}
}

/// <summary>
/// Write a line to the log, adding the SenderName and Message
/// (these parameters are on all MSBuild event argument objects)
Expand Down
Loading

0 comments on commit d5073c6

Please sign in to comment.