Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/BinlogTool/BinlogToolCommandBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.IO;
using Microsoft.Build.Logging.StructuredLogger;

namespace BinlogTool
{
public abstract class BinlogToolCommandBase
{
protected Build ReadBuild(string binLogFilePath, bool throwOnPathNotFound = true)
{
if (string.IsNullOrEmpty(binLogFilePath) || !File.Exists(binLogFilePath))
{
if(throwOnPathNotFound)
{
throw new FileNotFoundException("Specified binlog was not found.", binLogFilePath);
}

return null;
}

return BinaryLog.ReadBuild(binLogFilePath);
}
}
}
8 changes: 4 additions & 4 deletions src/BinlogTool/ListTools.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Build.Logging.StructuredLogger;

namespace BinlogTool
{
public class ListTools
public class ListTools : BinlogToolCommandBase
{
public void Run(string binLogFilePath)
{
var build = BinaryLog.ReadBuild(binLogFilePath);
var build = this.ReadBuild(binLogFilePath);
BuildAnalyzer.AnalyzeBuild(build);
var strings = build.StringTable.Instances.OrderBy(s => s).ToArray();

Expand Down Expand Up @@ -177,4 +177,4 @@ public static string NormalizePath(string path)
return string.Join('/', parts);
}
}
}
}
2 changes: 1 addition & 1 deletion src/BinlogTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ binlogtool search *.binlog search string

var binlogs = args[1];
var search = string.Join(" ", args.Skip(2));
Searcher.Search(binlogs, search);
new Searcher().Search2(binlogs, search);
return;
}

Expand Down
10 changes: 4 additions & 6 deletions src/BinlogTool/SaveFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace BinlogTool
{
public class SaveFiles
public class SaveFiles : BinlogToolCommandBase
{
private string[] args;

Expand All @@ -18,7 +18,8 @@ public SaveFiles(string[] args)

public void Run(string binlog, string outputDirectory, bool reconstruct = false)
{
if (string.IsNullOrEmpty(binlog) || !File.Exists(binlog))
Build build = this.ReadBuild(binlog, false);
if (build == null)
{
return;
}
Expand All @@ -29,9 +30,6 @@ public void Run(string binlog, string outputDirectory, bool reconstruct = false)
Directory.CreateDirectory(outputDirectory);
}

binlog = Path.GetFullPath(binlog);

var build = BinaryLog.ReadBuild(binlog);
SaveFilesFrom(build, outputDirectory);

if (reconstruct)
Expand Down Expand Up @@ -314,4 +312,4 @@ public static string FindCsc()
return cscFullPath;
}
}
}
}
8 changes: 4 additions & 4 deletions src/BinlogTool/SaveStrings.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System.Linq;
using System.Linq;
using Microsoft.Build.Logging.StructuredLogger;

namespace BinlogTool
{
public class SaveStrings
public class SaveStrings : BinlogToolCommandBase
{
public void Run(string binLogFilePath, string outputFilePath)
{
var build = BinaryLog.ReadBuild(binLogFilePath);
var build = this.ReadBuild(binLogFilePath);
var strings = build.StringTable.Instances.OrderBy(s => s).ToArray();

Serialization.WriteStringsToFile(outputFilePath, strings);
}
}
}
}
11 changes: 7 additions & 4 deletions src/BinlogTool/Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@

namespace BinlogTool
{
public static class Searcher
public class Searcher : BinlogToolCommandBase
{
public static void Search(string binlogs, string search)
=> new Searcher().Search2(binlogs, search);

public void Search2(string binlogs, string search)
{
var files = FindBinlogs(binlogs, recurse: true).ToList();
Search(files, search);
Expand Down Expand Up @@ -56,17 +59,17 @@ public static IEnumerable<string> FindBinlogs(string inputPath, bool recurse)
new EnumerationOptions() { IgnoreInaccessible = true, RecurseSubdirectories = recurse, });
}

private static void Search(IEnumerable<string> files, string search)
private void Search(IEnumerable<string> files, string search)
{
foreach (var file in files)
{
SearchInFile(file, search);
}
}

private static void SearchInFile(string binlogFilePath, string searchText)
private void SearchInFile(string binlogFilePath, string searchText)
{
var build = BinaryLog.ReadBuild(binlogFilePath);
var build = this.ReadBuild(binlogFilePath);
BuildAnalyzer.AnalyzeBuild(build);

var search = new Search(
Expand Down
107 changes: 28 additions & 79 deletions src/StructuredLogViewer.Core/SettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,57 +299,45 @@ public static void SaveCustomArguments(string projectFilePath, string newArgumen
}
}

private static bool enableTreeViewVirtualization = true;
private static T Get<T>(ref T backingField)
{
EnsureSettingsRead();
return backingField;
}

public static bool EnableTreeViewVirtualization
private static void Set<T>(ref T backingField, T value)
{
get
if (backingField == null && value == null
|| (backingField?.Equals(value) ?? false))
{
EnsureSettingsRead();
return enableTreeViewVirtualization;
return;
}

set
{
if (enableTreeViewVirtualization == value)
{
return;
}
backingField = value;
SaveSettings();
}

enableTreeViewVirtualization = value;
SaveSettings();
}
private static bool enableTreeViewVirtualization = true;

public static bool EnableTreeViewVirtualization
{
get => Get(ref enableTreeViewVirtualization);

set => Set(ref enableTreeViewVirtualization, value);
}

private static bool markResultsInTree = false;

public static bool MarkResultsInTree
{
get
{
EnsureSettingsRead();
return markResultsInTree;
}
get => Get(ref markResultsInTree);

set
{
if (markResultsInTree == value)
{
return;
}

markResultsInTree = value;
SaveSettings();
}
set => Set(ref markResultsInTree, value);
}

public static bool ShowConfigurationAndPlatform
{
get
{
EnsureSettingsRead();
return ProjectOrEvaluationHelper.ShowConfigurationAndPlatform;
}
get => Get(ref ProjectOrEvaluationHelper.ShowConfigurationAndPlatform);

set
{
Expand All @@ -367,64 +355,25 @@ public static bool ShowConfigurationAndPlatform
private static bool useDarkTheme = false;
public static bool UseDarkTheme
{
get
{
EnsureSettingsRead();
return useDarkTheme;
}

set
{
if (useDarkTheme == value)
{
return;
}
get => Get(ref useDarkTheme);

useDarkTheme = value;
SaveSettings();
}
set => Set(ref useDarkTheme, value);
}

private static string? windowPosition;
public static string? WindowPosition
{
get
{
EnsureSettingsRead();
return windowPosition;
}

set
{
if (windowPosition == value)
{
return;
}
get => Get(ref windowPosition);

windowPosition = value;
SaveSettings();
}
set => Set(ref windowPosition, value);
}

private static string? ignoreEmbeddedFiles;
public static string? IgnoreEmbeddedFiles
{
get
{
EnsureSettingsRead();
return ignoreEmbeddedFiles;
}
get => Get(ref ignoreEmbeddedFiles);

set
{
if (ignoreEmbeddedFiles == value)
{
return;
}

ignoreEmbeddedFiles = value;
SaveSettings();
}
set => Set(ref ignoreEmbeddedFiles, value);
}

private static void EnsureSettingsRead()
Expand Down
2 changes: 1 addition & 1 deletion src/StructuredLogViewer/MSBuildStructuredLogViewer.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
<file src="DeltaCompressionDotNet.dll" target="lib\net472" />
<file src="DeltaCompressionDotNet.MsDelta.dll" target="lib\net472" />
<file src="DeltaCompressionDotNet.PatchApi.dll" target="lib\net472" />
<file src="DotUtils.MsBuild.SensitiveDataDetector.dll" target="lib\net472" />
<file src="ICSharpCode.AvalonEdit.dll" target="lib\net472" />
<file src="ICSharpCode.SharpZipLib.dll" target="lib\net472" />
<file src="Microsoft.Build.dll" target="lib\net472" />
<file src="Microsoft.Build.Framework.dll" target="lib\net472" />
<file src="Microsoft.Build.Locator.dll" target="lib\net472" />
<file src="Microsoft.Build.Tasks.Core.dll" target="lib\net472" />
<file src="Microsoft.Build.SensitiveDataDetector.dll" target="lib\net472" />
<file src="Microsoft.Build.Utilities.Core.dll" target="lib\net472" />
<file src="Microsoft.Language.Xml.dll" target="lib\net472" />
<file src="Mono.Cecil.dll" target="lib\net472" />
Expand Down
2 changes: 1 addition & 1 deletion src/StructuredLogViewer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ private async void OpenLogFile(string filePath)
{
try
{
return Serialization.Read(filePath, progress.Progress);
return Serialization.Read(filePath, progress.Progress, ReaderSettings.Default);
}
catch (Exception ex)
{
Expand Down
Loading