Skip to content
Open
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
8 changes: 4 additions & 4 deletions Source/Tests/FileBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion Source/Tests/TestResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions Source/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -35,13 +36,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions, Version=4.19.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net45\FluentAssertions.dll</HintPath>
<Private>True</Private>
<Reference Include="FluentAssertions, Version=4.19.4.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.4\lib\net45\FluentAssertions.dll</HintPath>
</Reference>
<Reference Include="FluentAssertions.Core, Version=4.19.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net45\FluentAssertions.Core.dll</HintPath>
<Private>True</Private>
<Reference Include="FluentAssertions.Core, Version=4.19.4.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.4\lib\net45\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
Expand Down Expand Up @@ -70,9 +69,6 @@
<DependentUpon>TestResources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand All @@ -85,6 +81,9 @@
<Name>UnitySizeExplorer.WPF</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Source/Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.19.0" targetFramework="net452" />
<package id="FluentAssertions" version="4.19.4" targetFramework="net472" />
</packages>
6 changes: 3 additions & 3 deletions Source/UnitySizeExplorer.WPF/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>
</configuration>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Source/UnitySizeExplorer.WPF/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 26 additions & 19 deletions Source/UnitySizeExplorer.WPF/UnitySizeExplorer.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SpottedZebra.UnitySizeExplorer.WPF</RootNamespace>
<AssemblyName>UnityFileSizeExplorer</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -38,32 +39,35 @@
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
</PropertyGroup>
<ItemGroup>
<Reference Include="Caliburn.Micro, Version=3.0.3.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.Core.3.0.3\lib\net45\Caliburn.Micro.dll</HintPath>
<Private>True</Private>
<Reference Include="Caliburn.Micro, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.Core.3.2.0\lib\net45\Caliburn.Micro.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Platform, Version=3.0.3.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.0.3\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
<Private>True</Private>
<Reference Include="Caliburn.Micro.Platform, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.0.3.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.0.3\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
<Private>True</Private>
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
</Reference>
<Reference Include="LiveCharts, Version=0.9.3.5, Culture=neutral, PublicKeyToken=c5935629d38af058, processorArchitecture=MSIL">
<HintPath>..\packages\LiveCharts.0.9.3.5\lib\net45\LiveCharts.dll</HintPath>
<Private>True</Private>
<Reference Include="LiveCharts, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
<HintPath>..\packages\LiveCharts.0.9.6\lib\net45\LiveCharts.dll</HintPath>
</Reference>
<Reference Include="LiveCharts.Wpf, Version=0.9.3.5, Culture=neutral, PublicKeyToken=3b585c2a5f1a92c1, processorArchitecture=MSIL">
<HintPath>..\packages\LiveCharts.Wpf.0.9.3.5\lib\net45\LiveCharts.Wpf.dll</HintPath>
<Private>True</Private>
<Reference Include="LiveCharts.Wpf, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
<HintPath>..\packages\LiveCharts.Wpf.0.9.6\lib\net45\LiveCharts.Wpf.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.0.3\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Runtime.Serialization.Primitives, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.Serialization.Primitives.4.3.0\lib\net46\System.Runtime.Serialization.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand All @@ -87,8 +91,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resource.resx</DependentUpon>
</Compile>
<Compile Include="ViewModels\FileItemInfoNameComparer.cs" />
<Compile Include="ViewModels\FileItemInfoSizeComparer.cs" />
<Compile Include="ViewModels\FileItemViewModelSizeComparer.cs" />
<Compile Include="ViewModels\Pages\FileBuilder.cs" />
<Compile Include="ViewModels\PathAndSizeComparer.cs" />
<Compile Include="ViewModels\FileItemInfo.cs" />
<Compile Include="ViewModels\Pages\WorkspacePageViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
<Compile Include="ViewModels\FileItemViewModel.cs" />
Expand Down
16 changes: 16 additions & 0 deletions Source/UnitySizeExplorer.WPF/ViewModels/FileItemInfo.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace SpottedZebra.UnitySizeExplorer.WPF.ViewModels
{
using System.Collections.Generic;

public class FileItemInfoNameComparer : IComparer<FileItemInfo>
{
public int Compare(FileItemInfo x, FileItemInfo y)
{
return x.Name.CompareTo(y.Name);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace SpottedZebra.UnitySizeExplorer.WPF.ViewModels
{
using System.Collections.Generic;

public class FileItemInfoSizeComparer : IComparer<FileItemInfo>
{
public int Compare(FileItemInfo x, FileItemInfo y)
{
return y.Megabytes.CompareTo(x.Megabytes);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace SpottedZebra.UnitySizeExplorer.WPF.ViewModels
{
using System.Collections.Generic;

internal class FileItemViewModelSizeComparer : IComparer<FileItemViewModel>
{
public int Compare(FileItemViewModel x, FileItemViewModel y)
{
return y.Megabytes.CompareTo(x.Megabytes);
}
}
}
23 changes: 11 additions & 12 deletions Source/UnitySizeExplorer.WPF/ViewModels/Pages/FileBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace SpottedZebra.UnitySizeExplorer.WPF.ViewModels.Pages

public static class FileBuilder
{
public static async Task<List<Tuple<string, float>>> FromStream(Stream stream)
public static async Task<List<FileItemInfo>> FromStream(Stream stream)
{
List<Tuple<string, float>> files;
List<FileItemInfo> result;
using (var reader = new StreamReader(stream))
{
// Step 1: Read the raw input data and convert it into a list of <file names, file size> tuples.
files = new List<Tuple<string, float>>();
result = new List<FileItemInfo>();
var startProcessing = false;
string line;
while (!reader.EndOfStream)
Expand All @@ -33,22 +33,21 @@ public static async Task<List<Tuple<string, float>>> FromStream(Stream stream)
continue;
}

Tuple<string, float> data;
if (GetPathAndMegabytesFrom(line, out data))
if (GetPathAndMegabytesFrom(line, out FileItemInfo data))
{
files.Add(data);
result.Add(data);
}
else
{
break;
}
}

// 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;
}

/// <summary>
Expand All @@ -57,7 +56,7 @@ public static async Task<List<Tuple<string, float>>> FromStream(Stream stream)
/// <remarks>
/// Data comes in like: " {size} {unit} {percent}% {path}/{file}"
/// </remarks>
private static bool GetPathAndMegabytesFrom(string line, out Tuple<string, float> data)
private static bool GetPathAndMegabytesFrom(string line, out FileItemInfo data)
{
try
{
Expand All @@ -73,12 +72,12 @@ private static bool GetPathAndMegabytesFrom(string line, out Tuple<string, float
}

var path = line.Substring(line.IndexOf("% ", StringComparison.Ordinal) + 2);
data = new Tuple<string, float>(path, megabytes);
data = new FileItemInfo(path, megabytes);
return true;
}
catch
{
data = new Tuple<string, float>(string.Empty, -1);
data = new FileItemInfo(string.Empty, -1);
return false;
}
}
Expand Down
Loading