Merge pull request #125 from unoplatform/dev/jela/binlog-failsafe

fix: Failsafe on "Found invalid data while decoding" binlog replay from controller
This commit is contained in:
Jérôme Laban 2020-07-13 10:13:18 -04:00 коммит произвёл GitHub
Родитель 5bec09423b cdd9ef8f7c
Коммит 894a8edf73
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 18 добавлений и 8 удалений

Просмотреть файл

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Uno.SourceGeneration.Helpers
{
@ -11,17 +12,26 @@ namespace Uno.SourceGeneration.Helpers
/// <summary>
/// Replays the provided binlog file in the current build engine
/// </summary>
public static void Replay(IBuildEngine engine, string filePath)
public static void Replay(IBuildEngine engine, string filePath, TaskLoggingHelper log)
{
if (File.Exists(filePath))
{
var replaySource = new Microsoft.Build.Logging.BinaryLogReplayEventSource();
try
{
var replaySource = new Microsoft.Build.Logging.BinaryLogReplayEventSource();
replaySource.MessageRaised += (s, e) => engine.LogMessageEvent(e);
replaySource.WarningRaised += (s, e) => engine.LogWarningEvent(e);
replaySource.ErrorRaised += (s, e) => engine.LogErrorEvent(e);
replaySource.MessageRaised += (s, e) => engine.LogMessageEvent(e);
replaySource.WarningRaised += (s, e) => engine.LogWarningEvent(e);
replaySource.ErrorRaised += (s, e) => engine.LogErrorEvent(e);
replaySource.Replay(filePath);
replaySource.Replay(filePath);
}
catch(Exception e)
{
var fileSize = File.Exists(filePath) ? new FileInfo(filePath).Length : -1;
log.LogWarning($"Failed to replay source generation controller build messages (path:{filePath}, size:{fileSize}) : {e}");
}
}
}
}

Просмотреть файл

@ -217,7 +217,7 @@ namespace Uno.SourceGeneratorTasks
responseTask.Wait(_sharedCompileCts.Token);
BinaryLoggerReplayHelper.Replay(BuildEngine, binlogFile);
BinaryLoggerReplayHelper.Replay(BuildEngine, binlogFile, Log);
if (responseTask.Result.Type == GenerationResponse.ResponseType.Completed)
{
@ -340,7 +340,7 @@ namespace Uno.SourceGeneratorTasks
process.WaitForExit();
}
BinaryLoggerReplayHelper.Replay(BuildEngine, binlogFile);
BinaryLoggerReplayHelper.Replay(BuildEngine, binlogFile, Log);
if (process.ExitCode == 0)
{