diff --git a/src/StructuredLogViewer/MainWindow.xaml.cs b/src/StructuredLogViewer/MainWindow.xaml.cs index 629b1b16..28d692ed 100644 --- a/src/StructuredLogViewer/MainWindow.xaml.cs +++ b/src/StructuredLogViewer/MainWindow.xaml.cs @@ -211,6 +211,7 @@ private async System.Threading.Tasks.Task UpdateApplicationAsync() { var versionText = result.Version.ToString(); message = "After restarting the app you will be on version " + versionText; + BinaryLogger.IsNewerVersionAvailable = true; FileAssociations.EnsureAssociationsSet(versionText); } else diff --git a/src/StructuredLogger/BinaryLogger/BinLogReader.cs b/src/StructuredLogger/BinaryLogger/BinLogReader.cs index 62a77c8f..b9a0382a 100644 --- a/src/StructuredLogger/BinaryLogger/BinLogReader.cs +++ b/src/StructuredLogger/BinaryLogger/BinLogReader.cs @@ -66,13 +66,7 @@ public void Replay(Stream stream, Progress progress) OnFileFormatVersionRead?.Invoke(fileFormatVersion); - // the log file is written using a newer version of file format - // that we don't know how to read - if (fileFormatVersion > BinaryLogger.FileFormatVersion) - { - var text = $"Unsupported log file format. Latest supported version is {BinaryLogger.FileFormatVersion}, the log file has version {fileFormatVersion}."; - throw new NotSupportedException(text); - } + EnsureFileFormatVersionKnown(fileFormatVersion); // Use a producer-consumer queue so that IO can happen on one thread // while processing can happen on another thread decoupled. The speed @@ -143,6 +137,21 @@ public void Replay(Stream stream, Progress progress) } } + private void EnsureFileFormatVersionKnown(int fileFormatVersion) + { + // the log file is written using a newer version of file format + // that we don't know how to read + if (fileFormatVersion > BinaryLogger.FileFormatVersion) + { + var text = $"Unsupported log file format. Latest supported version is {BinaryLogger.FileFormatVersion}, the log file has version {fileFormatVersion}."; + if (BinaryLogger.IsNewerVersionAvailable) + { + text += " Update available - restart this instance to automatically use newer version."; + } + throw new NotSupportedException(text); + } + } + private class DisposableEnumerable : IEnumerable, IDisposable { private IEnumerable enumerable; @@ -210,13 +219,7 @@ public IEnumerable ReadRecordsFromDecompressedStream(Stream decompressed int fileFormatVersion = binaryReader.ReadInt32(); - // the log file is written using a newer version of file format - // that we don't know how to read - if (fileFormatVersion > BinaryLogger.FileFormatVersion) - { - var text = $"Unsupported log file format. Latest supported version is {BinaryLogger.FileFormatVersion}, the log file has version {fileFormatVersion}."; - throw new NotSupportedException(text); - } + EnsureFileFormatVersionKnown(fileFormatVersion); long lengthOfBlobsAddedLastTime = 0; diff --git a/src/StructuredLogger/BinaryLogger/BinaryLogger.cs b/src/StructuredLogger/BinaryLogger/BinaryLogger.cs index eb4f4675..47d539d3 100644 --- a/src/StructuredLogger/BinaryLogger/BinaryLogger.cs +++ b/src/StructuredLogger/BinaryLogger/BinaryLogger.cs @@ -61,6 +61,8 @@ public sealed class BinaryLogger : ILogger // - AssemblyLoadBuildEventArgs internal const int FileFormatVersion = 16; + public static bool IsNewerVersionAvailable { get; set; } + private Stream stream; private BinaryWriter binaryWriter; private BuildEventArgsWriter eventArgsWriter;