From 8cb781fe58e4f0eb407ad12612caad727f07fab8 Mon Sep 17 00:00:00 2001 From: Scott Steffes Date: Fri, 18 Jun 2021 14:17:14 +0900 Subject: [PATCH 1/2] Update Nuget Packages and .NET version --- Source/Tests/TestResources.Designer.cs | 2 +- Source/Tests/Tests.csproj | 19 +++++---- Source/Tests/packages.config | 2 +- Source/UnitySizeExplorer.WPF/App.config | 6 +-- .../Properties/Resources.Designer.cs | 2 +- .../Properties/Settings.Designer.cs | 2 +- .../Resource.Designer.cs | 2 +- .../UnitySizeExplorer.WPF.csproj | 40 ++++++++++--------- Source/UnitySizeExplorer.WPF/packages.config | 10 +++-- 9 files changed, 45 insertions(+), 40 deletions(-) diff --git a/Source/Tests/TestResources.Designer.cs b/Source/Tests/TestResources.Designer.cs index cf921d3..f7e7539 100644 --- a/Source/Tests/TestResources.Designer.cs +++ b/Source/Tests/TestResources.Designer.cs @@ -19,7 +19,7 @@ namespace Tests { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class TestResources { diff --git a/Source/Tests/Tests.csproj b/Source/Tests/Tests.csproj index 2ebf8e7..2f2d4a1 100644 --- a/Source/Tests/Tests.csproj +++ b/Source/Tests/Tests.csproj @@ -8,7 +8,7 @@ Properties Tests Tests - v4.5.2 + v4.7.2 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10.0 @@ -16,6 +16,7 @@ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages False UnitTest + true @@ -35,13 +36,11 @@ 4 - - ..\packages\FluentAssertions.4.19.0\lib\net45\FluentAssertions.dll - True + + ..\packages\FluentAssertions.4.19.4\lib\net45\FluentAssertions.dll - - ..\packages\FluentAssertions.4.19.0\lib\net45\FluentAssertions.Core.dll - True + + ..\packages\FluentAssertions.4.19.4\lib\net45\FluentAssertions.Core.dll @@ -70,9 +69,6 @@ TestResources.resx - - - ResXFileCodeGenerator @@ -85,6 +81,9 @@ UnitySizeExplorer.WPF + + + diff --git a/Source/Tests/packages.config b/Source/Tests/packages.config index f6e840b..3816084 100644 --- a/Source/Tests/packages.config +++ b/Source/Tests/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Source/UnitySizeExplorer.WPF/App.config b/Source/UnitySizeExplorer.WPF/App.config index 88fa402..ecdcf8a 100644 --- a/Source/UnitySizeExplorer.WPF/App.config +++ b/Source/UnitySizeExplorer.WPF/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/Source/UnitySizeExplorer.WPF/Properties/Resources.Designer.cs b/Source/UnitySizeExplorer.WPF/Properties/Resources.Designer.cs index c894a1f..6385b30 100644 --- a/Source/UnitySizeExplorer.WPF/Properties/Resources.Designer.cs +++ b/Source/UnitySizeExplorer.WPF/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace SpottedZebra.UnitySizeExplorer.WPF.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/Source/UnitySizeExplorer.WPF/Properties/Settings.Designer.cs b/Source/UnitySizeExplorer.WPF/Properties/Settings.Designer.cs index 896fea3..8d02133 100644 --- a/Source/UnitySizeExplorer.WPF/Properties/Settings.Designer.cs +++ b/Source/UnitySizeExplorer.WPF/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace SpottedZebra.UnitySizeExplorer.WPF.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/Source/UnitySizeExplorer.WPF/Resource.Designer.cs b/Source/UnitySizeExplorer.WPF/Resource.Designer.cs index 61389b6..ff3b898 100644 --- a/Source/UnitySizeExplorer.WPF/Resource.Designer.cs +++ b/Source/UnitySizeExplorer.WPF/Resource.Designer.cs @@ -19,7 +19,7 @@ namespace SpottedZebra.UnitySizeExplorer.WPF { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resource { diff --git a/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj b/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj index 6362d03..89d10cb 100644 --- a/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj +++ b/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj @@ -9,11 +9,12 @@ Properties SpottedZebra.UnitySizeExplorer.WPF UnityFileSizeExplorer - v4.5.2 + v4.7.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 true + AnyCPU @@ -38,32 +39,35 @@ false - - ..\packages\Caliburn.Micro.Core.3.0.3\lib\net45\Caliburn.Micro.dll - True + + ..\packages\Caliburn.Micro.Core.3.2.0\lib\net45\Caliburn.Micro.dll - - ..\packages\Caliburn.Micro.3.0.3\lib\net45\Caliburn.Micro.Platform.dll - True + + ..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.dll - - ..\packages\Caliburn.Micro.3.0.3\lib\net45\Caliburn.Micro.Platform.Core.dll - True + + ..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll - - ..\packages\LiveCharts.0.9.3.5\lib\net45\LiveCharts.dll - True + + ..\packages\LiveCharts.0.9.6\lib\net45\LiveCharts.dll - - ..\packages\LiveCharts.Wpf.0.9.3.5\lib\net45\LiveCharts.Wpf.dll - True + + ..\packages\LiveCharts.Wpf.0.9.6\lib\net45\LiveCharts.Wpf.dll + + + ..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll - - ..\packages\Caliburn.Micro.3.0.3\lib\net45\System.Windows.Interactivity.dll + + + ..\packages\System.Runtime.Serialization.Primitives.4.3.0\lib\net46\System.Runtime.Serialization.Primitives.dll + True True + + ..\packages\Caliburn.Micro.3.2.0\lib\net45\System.Windows.Interactivity.dll + diff --git a/Source/UnitySizeExplorer.WPF/packages.config b/Source/UnitySizeExplorer.WPF/packages.config index 7597f3f..1adda48 100644 --- a/Source/UnitySizeExplorer.WPF/packages.config +++ b/Source/UnitySizeExplorer.WPF/packages.config @@ -1,7 +1,9 @@  - - - - + + + + + + \ No newline at end of file From ad751d31661e5751328e3badf50e978a042f6268 Mon Sep 17 00:00:00 2001 From: Scott Steffes Date: Fri, 18 Jun 2021 14:53:18 +0900 Subject: [PATCH 2/2] Sort each level of file hierarchy by size --- Source/Tests/FileBuilderTest.cs | 8 +++--- .../UnitySizeExplorer.WPF.csproj | 5 +++- .../ViewModels/FileItemInfo.cs | 16 +++++++++++ .../ViewModels/FileItemInfoNameComparer.cs | 12 +++++++++ .../ViewModels/FileItemInfoSizeComparer.cs | 12 +++++++++ .../FileItemViewModelSizeComparer.cs | 12 +++++++++ .../ViewModels/Pages/FileBuilder.cs | 23 ++++++++-------- .../Pages/WorkspacePageViewModel.cs | 27 ++++++++++++++----- .../ViewModels/PathAndSizeComparer.cs | 13 --------- 9 files changed, 92 insertions(+), 36 deletions(-) create mode 100644 Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfo.cs create mode 100644 Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfoNameComparer.cs create mode 100644 Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfoSizeComparer.cs create mode 100644 Source/UnitySizeExplorer.WPF/ViewModels/FileItemViewModelSizeComparer.cs delete mode 100644 Source/UnitySizeExplorer.WPF/ViewModels/PathAndSizeComparer.cs diff --git a/Source/Tests/FileBuilderTest.cs b/Source/Tests/FileBuilderTest.cs index ad6b5e5..2b03144 100644 --- a/Source/Tests/FileBuilderTest.cs +++ b/Source/Tests/FileBuilderTest.cs @@ -46,8 +46,8 @@ public void LogWithSingleBlockShouldReturnGivenInformation() var first = result.First(); result.Should().HaveCount(2); - first.Item1.Should().Be("file1"); - first.Item2.Should().Be(2.1f); + first.Name.Should().Be("file1"); + first.Megabytes.Should().Be(2.1f); } [TestMethod] @@ -65,8 +65,8 @@ public void LogWithMultipleBlocksShouldReturnGivenInformation() var first = result.First(); result.Should().HaveCount(6); - first.Item1.Should().Be("file1"); - first.Item2.Should().Be(2.1f); + first.Name.Should().Be("file1"); + first.Megabytes.Should().Be(2.1f); } } } \ No newline at end of file diff --git a/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj b/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj index 89d10cb..53c25df 100644 --- a/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj +++ b/Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj @@ -91,8 +91,11 @@ True Resource.resx + + + - + diff --git a/Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfo.cs b/Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfo.cs new file mode 100644 index 0000000..fc5bd4c --- /dev/null +++ b/Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfo.cs @@ -0,0 +1,16 @@ +namespace SpottedZebra.UnitySizeExplorer.WPF.ViewModels +{ + using System.Collections.Generic; + + public struct FileItemInfo + { + public string Name; + public float Megabytes; + + public FileItemInfo(string name, float megabytes) + { + this.Name = name; + this.Megabytes = megabytes; + } + } +} diff --git a/Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfoNameComparer.cs b/Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfoNameComparer.cs new file mode 100644 index 0000000..2cfac69 --- /dev/null +++ b/Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfoNameComparer.cs @@ -0,0 +1,12 @@ +namespace SpottedZebra.UnitySizeExplorer.WPF.ViewModels +{ + using System.Collections.Generic; + + public class FileItemInfoNameComparer : IComparer + { + public int Compare(FileItemInfo x, FileItemInfo y) + { + return x.Name.CompareTo(y.Name); + } + } +} \ No newline at end of file diff --git a/Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfoSizeComparer.cs b/Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfoSizeComparer.cs new file mode 100644 index 0000000..8bafc8d --- /dev/null +++ b/Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfoSizeComparer.cs @@ -0,0 +1,12 @@ +namespace SpottedZebra.UnitySizeExplorer.WPF.ViewModels +{ + using System.Collections.Generic; + + public class FileItemInfoSizeComparer : IComparer + { + public int Compare(FileItemInfo x, FileItemInfo y) + { + return y.Megabytes.CompareTo(x.Megabytes); + } + } +} diff --git a/Source/UnitySizeExplorer.WPF/ViewModels/FileItemViewModelSizeComparer.cs b/Source/UnitySizeExplorer.WPF/ViewModels/FileItemViewModelSizeComparer.cs new file mode 100644 index 0000000..b703dff --- /dev/null +++ b/Source/UnitySizeExplorer.WPF/ViewModels/FileItemViewModelSizeComparer.cs @@ -0,0 +1,12 @@ +namespace SpottedZebra.UnitySizeExplorer.WPF.ViewModels +{ + using System.Collections.Generic; + + internal class FileItemViewModelSizeComparer : IComparer + { + public int Compare(FileItemViewModel x, FileItemViewModel y) + { + return y.Megabytes.CompareTo(x.Megabytes); + } + } +} diff --git a/Source/UnitySizeExplorer.WPF/ViewModels/Pages/FileBuilder.cs b/Source/UnitySizeExplorer.WPF/ViewModels/Pages/FileBuilder.cs index c538dd5..976433f 100644 --- a/Source/UnitySizeExplorer.WPF/ViewModels/Pages/FileBuilder.cs +++ b/Source/UnitySizeExplorer.WPF/ViewModels/Pages/FileBuilder.cs @@ -8,13 +8,13 @@ namespace SpottedZebra.UnitySizeExplorer.WPF.ViewModels.Pages public static class FileBuilder { - public static async Task>> FromStream(Stream stream) + public static async Task> FromStream(Stream stream) { - List> files; + List result; using (var reader = new StreamReader(stream)) { // Step 1: Read the raw input data and convert it into a list of tuples. - files = new List>(); + result = new List(); var startProcessing = false; string line; while (!reader.EndOfStream) @@ -33,10 +33,9 @@ public static async Task>> FromStream(Stream stream) continue; } - Tuple data; - if (GetPathAndMegabytesFrom(line, out data)) + if (GetPathAndMegabytesFrom(line, out FileItemInfo data)) { - files.Add(data); + result.Add(data); } else { @@ -44,11 +43,11 @@ public static async Task>> FromStream(Stream stream) } } - // Step 2: Sort the list of files by file name. - files.Sort(new PathAndSizeComparer()); + // Step 2: Sort the list of files by file size. + result.Sort(new FileItemInfoSizeComparer()); } - return files; + return result; } /// @@ -57,7 +56,7 @@ public static async Task>> FromStream(Stream stream) /// /// Data comes in like: " {size} {unit} {percent}% {path}/{file}" /// - private static bool GetPathAndMegabytesFrom(string line, out Tuple data) + private static bool GetPathAndMegabytesFrom(string line, out FileItemInfo data) { try { @@ -73,12 +72,12 @@ private static bool GetPathAndMegabytesFrom(string line, out Tuple(path, megabytes); + data = new FileItemInfo(path, megabytes); return true; } catch { - data = new Tuple(string.Empty, -1); + data = new FileItemInfo(string.Empty, -1); return false; } } diff --git a/Source/UnitySizeExplorer.WPF/ViewModels/Pages/WorkspacePageViewModel.cs b/Source/UnitySizeExplorer.WPF/ViewModels/Pages/WorkspacePageViewModel.cs index 3738cd7..17659b9 100644 --- a/Source/UnitySizeExplorer.WPF/ViewModels/Pages/WorkspacePageViewModel.cs +++ b/Source/UnitySizeExplorer.WPF/ViewModels/Pages/WorkspacePageViewModel.cs @@ -15,6 +15,7 @@ /// internal class WorkspacePageViewModel : Screen { + private static readonly FileItemViewModelSizeComparer SizeComparer = new FileItemViewModelSizeComparer(); private readonly IConductor conductor; /// @@ -141,7 +142,7 @@ private static void PrepareRoots(List roots) } } - private static List BuildTreeFromFiles(List> files) + private static List BuildTreeFromFiles(List files) { // Step 3: Contruct a tree based on files var cache = new Dictionary(); @@ -151,13 +152,13 @@ private static List BuildTreeFromFiles(List BuildTreeFromFiles(List + /// Sorts each level of the tree. + /// + private static void SortTree(List fileItems) + { + fileItems.Sort(SizeComparer); + foreach (var item in fileItems) + { + SortTree(item.Children); } } diff --git a/Source/UnitySizeExplorer.WPF/ViewModels/PathAndSizeComparer.cs b/Source/UnitySizeExplorer.WPF/ViewModels/PathAndSizeComparer.cs deleted file mode 100644 index e7d7dfe..0000000 --- a/Source/UnitySizeExplorer.WPF/ViewModels/PathAndSizeComparer.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace SpottedZebra.UnitySizeExplorer.WPF.ViewModels -{ - using System; - using System.Collections.Generic; - - internal class PathAndSizeComparer : IComparer> - { - public int Compare(Tuple x, Tuple y) - { - return x.Item1.CompareTo(y.Item1); - } - } -}