private void ReadBlob(BinaryLogRecordKind kind) { int length = ReadInt32(); byte[] bytes = binaryReader.ReadBytes(length); OnBlobRead?.Invoke(kind, bytes); }
public void WriteBlob(BinaryLogRecordKind kind, byte[] bytes) { // write the blob directly to the underlying writer, // bypassing the memory stream using var redirection = RedirectWritesToOriginalWriter(); Write(kind); Write(bytes.Length); Write(bytes); }
/// <summary> /// Reads the next log record from the binary reader. If there are no more records, returns null. /// </summary> public BuildEventArgs Read() { BinaryLogRecordKind recordKind = (BinaryLogRecordKind)ReadInt32(); while (IsBlob(recordKind)) { ReadBlob(recordKind); recordKind = (BinaryLogRecordKind)ReadInt32(); } BuildEventArgs result = null; switch (recordKind) { case BinaryLogRecordKind.EndOfFile: break; case BinaryLogRecordKind.BuildStarted: result = ReadBuildStartedEventArgs(); break; case BinaryLogRecordKind.BuildFinished: result = ReadBuildFinishedEventArgs(); break; case BinaryLogRecordKind.ProjectStarted: result = ReadProjectStartedEventArgs(); break; case BinaryLogRecordKind.ProjectFinished: result = ReadProjectFinishedEventArgs(); break; case BinaryLogRecordKind.TargetStarted: result = ReadTargetStartedEventArgs(); break; case BinaryLogRecordKind.TargetFinished: result = ReadTargetFinishedEventArgs(); break; case BinaryLogRecordKind.TaskStarted: result = ReadTaskStartedEventArgs(); break; case BinaryLogRecordKind.TaskFinished: result = ReadTaskFinishedEventArgs(); break; case BinaryLogRecordKind.Error: result = ReadBuildErrorEventArgs(); break; case BinaryLogRecordKind.Warning: result = ReadBuildWarningEventArgs(); break; case BinaryLogRecordKind.Message: result = ReadBuildMessageEventArgs(); break; case BinaryLogRecordKind.CriticalBuildMessage: result = ReadCriticalBuildMessageEventArgs(); break; case BinaryLogRecordKind.TaskCommandLine: result = ReadTaskCommandLineEventArgs(); break; case BinaryLogRecordKind.ProjectEvaluationStarted: result = ReadProjectEvaluationStartedEventArgs(); break; case BinaryLogRecordKind.ProjectEvaluationFinished: result = ReadProjectEvaluationFinishedEventArgs(); break; case BinaryLogRecordKind.ProjectImported: result = ReadProjectImportedEventArgs(); break; case BinaryLogRecordKind.TargetSkipped: result = ReadTargetSkippedEventArgs(); break; default: break; } return(result); }
/// <summary> /// For now it's just the ProjectImportArchive. /// </summary> private static bool IsBlob(BinaryLogRecordKind recordKind) { return(recordKind == BinaryLogRecordKind.ProjectImportArchive); }
private void Write(BinaryLogRecordKind kind) { Write((int)kind); }
public void WriteBlob(BinaryLogRecordKind kind, byte[] bytes) { Write(kind); Write(bytes.Length); Write(bytes); }
private void OnBlobRead(BinaryLogRecordKind kind, byte[] bytes) { BlobCount += 1; BlobTotalSize += bytes.Length; BlobLargest = Math.Max(BlobLargest, bytes.Length); }
/// <summary> /// Reads the next log record from the binary reader. If there are no more records, returns null. /// </summary> public BuildEventArgs Read() { BinaryLogRecordKind recordKind = (BinaryLogRecordKind)ReadInt32(); // Skip over data storage records since they don't result in a BuildEventArgs. // just ingest their data and continue. while (IsAuxiliaryRecord(recordKind)) { // these are ordered by commonality if (recordKind == BinaryLogRecordKind.String) { ReadStringRecord(); } else if (recordKind == BinaryLogRecordKind.NameValueList) { ReadNameValueList(); } else if (recordKind == BinaryLogRecordKind.ProjectImportArchive) { ReadBlob(recordKind); } recordNumber += 1; recordKind = (BinaryLogRecordKind)ReadInt32(); } BuildEventArgs result = null; switch (recordKind) { case BinaryLogRecordKind.EndOfFile: break; case BinaryLogRecordKind.BuildStarted: result = ReadBuildStartedEventArgs(); break; case BinaryLogRecordKind.BuildFinished: result = ReadBuildFinishedEventArgs(); break; case BinaryLogRecordKind.ProjectStarted: result = ReadProjectStartedEventArgs(); break; case BinaryLogRecordKind.ProjectFinished: result = ReadProjectFinishedEventArgs(); break; case BinaryLogRecordKind.TargetStarted: result = ReadTargetStartedEventArgs(); break; case BinaryLogRecordKind.TargetFinished: result = ReadTargetFinishedEventArgs(); break; case BinaryLogRecordKind.TaskStarted: result = ReadTaskStartedEventArgs(); break; case BinaryLogRecordKind.TaskFinished: result = ReadTaskFinishedEventArgs(); break; case BinaryLogRecordKind.Error: result = ReadBuildErrorEventArgs(); break; case BinaryLogRecordKind.Warning: result = ReadBuildWarningEventArgs(); break; case BinaryLogRecordKind.Message: result = ReadBuildMessageEventArgs(); break; case BinaryLogRecordKind.CriticalBuildMessage: result = ReadCriticalBuildMessageEventArgs(); break; case BinaryLogRecordKind.TaskCommandLine: result = ReadTaskCommandLineEventArgs(); break; case BinaryLogRecordKind.TaskParameter: result = ReadTaskParameterEventArgs(); break; case BinaryLogRecordKind.ProjectEvaluationStarted: result = ReadProjectEvaluationStartedEventArgs(); break; case BinaryLogRecordKind.ProjectEvaluationFinished: result = ReadProjectEvaluationFinishedEventArgs(); break; case BinaryLogRecordKind.ProjectImported: result = ReadProjectImportedEventArgs(); break; case BinaryLogRecordKind.TargetSkipped: result = ReadTargetSkippedEventArgs(); break; case BinaryLogRecordKind.EnvironmentVariableRead: result = ReadEnvironmentVariableReadEventArgs(); break; case BinaryLogRecordKind.PropertyReassignment: result = ReadPropertyReassignmentEventArgs(); break; case BinaryLogRecordKind.UninitializedPropertyRead: result = ReadUninitializedPropertyReadEventArgs(); break; case BinaryLogRecordKind.PropertyInitialValueSet: result = ReadPropertyInitialValueSetEventArgs(); break; default: break; } recordNumber += 1; return(result); }
private static bool IsAuxiliaryRecord(BinaryLogRecordKind recordKind) { return(recordKind == BinaryLogRecordKind.String || recordKind == BinaryLogRecordKind.NameValueList || recordKind == BinaryLogRecordKind.ProjectImportArchive); }