A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Fixing checksum comparison issue (#396) (#406)
Attila Stéger70e4497bebb9
diff --git a/src/dev/DevToys.Startup/Package.appxmanifest b/src/dev/DevToys.Startup/Package.appxmanifestindex 3bec99355..c7b45eb3b 100644--- a/src/dev/DevToys.Startup/Package.appxmanifest+++ b/src/dev/DevToys.Startup/Package.appxmanifest@@ -1,4 +1,4 @@-<?xml version="1.0" encoding="utf-8"?>+<?xml version="1.0" encoding="utf-8"?><Packagexmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"diff --git a/src/dev/impl/DevToys/DevToys.csproj b/src/dev/impl/DevToys/DevToys.csprojindex 566783b8d..333ce85ab 100644--- a/src/dev/impl/DevToys/DevToys.csproj+++ b/src/dev/impl/DevToys/DevToys.csproj@@ -59,6 +59,7 @@<Compile Include="Messages\PinToolToStartMessage.cs" /><Compile Include="Messages\OpenToolInNewWindowMessage.cs" /><Compile Include="Messages\ChangeSelectedMenuItemMessage.cs" />+ <Compile Include="Models\HashComparisonResult.cs" /><Compile Include="Models\HashingAlgorithm.cs" /><Compile Include="Models\HashingAlgorithmDisplayPair.cs" /><Compile Include="Models\HashingProgress.cs" />diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.csindex 731ffd521..ba2ed3efe 100644--- a/src/dev/impl/DevToys/LanguageManager.cs+++ b/src/dev/impl/DevToys/LanguageManager.cs@@ -412,6 +412,16 @@ namespace DevToys/// Gets the resource SearchKeywords./// </summary>public string SearchKeywords => _resources.GetString("SearchKeywords");++ /// <summary>+ /// Gets the resource HashesMatch.+ /// </summary>+ public string HashesMatch => _resources.GetString("HashesMatch");++ /// <summary>+ /// Gets the resource HashesMismatch.+ /// </summary>+ public string HashesMismatch => _resources.GetString("HashesMismatch");}public class ColorBlindnessSimulatorStrings : ObservableObjectdiff --git a/src/dev/impl/DevToys/Models/HashComparisonResult.cs b/src/dev/impl/DevToys/Models/HashComparisonResult.csnew file mode 100644index 000000000..83131bf5e--- /dev/null+++ b/src/dev/impl/DevToys/Models/HashComparisonResult.cs@@ -0,0 +1,38 @@+#nullable enable++using Microsoft.UI.Xaml.Controls;++namespace DevToys.Models+{+ /// <summary>+ /// Contains information regarding the result of the hash comparison.+ /// </summary>+ internal sealed class HashComparisonResult+ {+ /// <summary>+ /// Initializes a new instance of the <see cref="HashComparisonResult"/> class.+ /// </summary>+ /// <param name="severity">The severity of the comparison result message</param>+ /// <param name="message">The message that can be shown to the user</param>+ internal HashComparisonResult(InfoBarSeverity severity, string message)+ {+ Severity = severity;+ Message = message;+ }++ /// <summary>+ /// Gets a value that represents the severity of the comparison result message+ /// </summary>+ public InfoBarSeverity Severity { get; }++ /// <summary>+ /// Gets a value that represents the message can be shown to the user+ /// </summary>+ public string Message { get; }++ /// <summary>+ /// Gets the default-empty comparison result.+ /// </summary>+ public static HashComparisonResult? None { get; }+ }+}diff --git a/src/dev/impl/DevToys/Strings/cs-CZ/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/cs-CZ/CheckSumGenerator.reswindex f43258230..7de31d954 100644--- a/src/dev/impl/DevToys/Strings/cs-CZ/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/cs-CZ/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/de-DE/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/de-DE/CheckSumGenerator.reswindex 0e31a4652..0430af8b0 100644--- a/src/dev/impl/DevToys/Strings/de-DE/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/de-DE/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/en-US/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/en-US/CheckSumGenerator.reswindex 0e31a4652..0430af8b0 100644--- a/src/dev/impl/DevToys/Strings/en-US/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/en-US/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/es-AR/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/es-AR/CheckSumGenerator.reswindex 0e31a4652..0430af8b0 100644--- a/src/dev/impl/DevToys/Strings/es-AR/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/es-AR/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/es-ES/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/es-ES/CheckSumGenerator.reswindex 0e31a4652..0430af8b0 100644--- a/src/dev/impl/DevToys/Strings/es-ES/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/es-ES/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/fr-FR/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/fr-FR/CheckSumGenerator.reswindex 0e31a4652..0430af8b0 100644--- a/src/dev/impl/DevToys/Strings/fr-FR/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/fr-FR/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/hu-HU/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/hu-HU/CheckSumGenerator.reswindex 0e31a4652..5ea141a46 100644--- a/src/dev/impl/DevToys/Strings/hu-HU/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/hu-HU/CheckSumGenerator.resw@@ -118,42 +118,48 @@<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader><data name="AccessibleName" xml:space="preserve">- <value>Checksum Generator tool</value>+ <value>Checksum Generátor eszköz</value></data><data name="Cancel" xml:space="preserve">- <value>Cancel</value>+ <value>Mégsem</value></data><data name="Configuration" xml:space="preserve">- <value>Configuration</value>+ <value>Beállítások</value></data><data name="Description" xml:space="preserve">- <value>Generate a hash with Checksum based on a file</value>+ <value>Hash készítése fájl alapján</value></data><data name="HashingAlgorithmDescription" xml:space="preserve">- <value>Select which hashing algorithm you want to use</value>+ <value>Válassza ki a használni kívánt hash függvényt</value></data><data name="HashingAlgorithmTitle" xml:space="preserve">- <value>Hashing Algorithm</value>+ <value>Hash függvény</value></data><data name="Input" xml:space="preserve">- <value>Input</value>+ <value>Bemenet</value></data><data name="MenuDisplayName" xml:space="preserve"><value>Checksum</value></data><data name="Output" xml:space="preserve">- <value>Output</value>+ <value>Kimenet</value></data><data name="OutputComparer" xml:space="preserve">- <value>Output Comparer</value>+ <value>Összehasonlító eredmény</value></data><data name="SearchDisplayName" xml:space="preserve"><value>Checksum Generator</value></data><data name="Uppercase" xml:space="preserve">- <value>Uppercase</value>+ <value>Nagybetűs</value></data><data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>A hashek megegyeznek.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>A hashek nem egyeznek meg.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/id-ID/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/id-ID/CheckSumGenerator.reswindex 9ee25ec69..de92a49d9 100644--- a/src/dev/impl/DevToys/Strings/id-ID/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/id-ID/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/it-IT/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/it-IT/CheckSumGenerator.reswindex bf272caca..c6c6bd987 100644--- a/src/dev/impl/DevToys/Strings/it-IT/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/it-IT/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/ja-JP/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/ja-JP/CheckSumGenerator.reswindex 46adebfe8..71ab71e7b 100644--- a/src/dev/impl/DevToys/Strings/ja-JP/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/ja-JP/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value>Checksum</value></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/ko-KR/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/ko-KR/CheckSumGenerator.reswindex 22986da1e..83fa9345f 100644--- a/src/dev/impl/DevToys/Strings/ko-KR/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/ko-KR/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value>Checksum</value></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/pl-PL/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/pl-PL/CheckSumGenerator.reswindex 0e31a4652..0430af8b0 100644--- a/src/dev/impl/DevToys/Strings/pl-PL/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/pl-PL/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/pt-PT/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/pt-PT/CheckSumGenerator.reswindex 504fb5d97..075d40aa2 100644--- a/src/dev/impl/DevToys/Strings/pt-PT/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/pt-PT/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/ru-RU/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/ru-RU/CheckSumGenerator.reswindex 0e31a4652..0430af8b0 100644--- a/src/dev/impl/DevToys/Strings/ru-RU/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/ru-RU/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/zh-Hans/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/zh-Hans/CheckSumGenerator.reswindex 5a1998bb6..b37611000 100644--- a/src/dev/impl/DevToys/Strings/zh-Hans/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/zh-Hans/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/zh-Hant/CheckSumGenerator.resw b/src/dev/impl/DevToys/Strings/zh-Hant/CheckSumGenerator.reswindex 7da99f9b0..6f409fc5f 100644--- a/src/dev/impl/DevToys/Strings/zh-Hant/CheckSumGenerator.resw+++ b/src/dev/impl/DevToys/Strings/zh-Hant/CheckSumGenerator.resw@@ -156,4 +156,10 @@<data name="SearchKeywords" xml:space="preserve"><value /></data>+ <data name="HashesMatch" xml:space="preserve">+ <value>The hashes are the same.</value>+ </data>+ <data name="HashesMismatch" xml:space="preserve">+ <value>The hashes are different.</value>+ </data></root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/ViewModels/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolViewModel.csindex ce067605c..11c8079b1 100644--- a/src/dev/impl/DevToys/ViewModels/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolViewModel.cs+++ b/src/dev/impl/DevToys/ViewModels/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolViewModel.cs@@ -21,6 +21,7 @@ using DevToys.Shared.Core.Threading;using DevToys.Views.Tools.CheckSumGenerator;using Microsoft.Toolkit.Mvvm.ComponentModel;using Microsoft.Toolkit.Mvvm.Input;+using Microsoft.UI.Xaml.Controls;using Windows.ApplicationModel.DataTransfer;using Windows.Storage;@@ -61,6 +62,7 @@ namespace DevToys.ViewModels.Tools.CheckSumGeneratorprivate bool _toolSuccessfullyWorked;private bool _hasCancelledCalculation;private bool _shouldDisplayProgress;+ private HashComparisonResult? _hashComparisonResult;private HashingAlgorithmDisplayPair? _outputHashingAlgorithm;private readonly Queue<Task> _computationTaskQueue = new();@@ -132,13 +134,27 @@ namespace DevToys.ViewModels.Tools.CheckSumGeneratorinternal string? Output{get => _output;- set => SetProperty(ref _output, value);+ set+ {+ SetProperty(ref _output, value);+ HashComparisonResult = EvaluateOutputComparisonResult(value, OutputComparer);+ }}internal string? OutputComparer{get => _outputComparer;- set => SetProperty(ref _outputComparer, value);+ set+ {+ SetProperty(ref _outputComparer, value);+ HashComparisonResult = EvaluateOutputComparisonResult(Output, value);+ }+ }++ internal HashComparisonResult? HashComparisonResult+ {+ get => _hashComparisonResult;+ private set => SetProperty(ref _hashComparisonResult, value);}/// <summary>@@ -343,5 +359,22 @@ namespace DevToys.ViewModels.Tools.CheckSumGeneratorHashingAlgorithm.SHA512 => SHA512.Create(),_ => throw new ArgumentException("Hash Algorithm not supported", nameof(HashingAlgorithm))};++ /// <summary>+ /// Evaluates the Output Comparison.+ /// </summary>+ private HashComparisonResult? EvaluateOutputComparisonResult(string? output, string? comparerOutput)+ {+ if (!string.IsNullOrEmpty(output) && !string.IsNullOrEmpty(comparerOutput))+ {+ return string.Equals(output, comparerOutput, StringComparison.OrdinalIgnoreCase)+ ? new HashComparisonResult(InfoBarSeverity.Success, Strings.HashesMatch)+ : new HashComparisonResult(InfoBarSeverity.Error, Strings.HashesMismatch);+ }+ else+ {+ return HashComparisonResult.None;+ }+ }}}diff --git a/src/dev/impl/DevToys/Views/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolPage.xamlindex 2563b9cd1..725bb4c02 100644--- a/src/dev/impl/DevToys/Views/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolPage.xaml+++ b/src/dev/impl/DevToys/Views/Tools/Generators/CheckSumGenerator/CheckSumGeneratorToolPage.xaml@@ -13,6 +13,7 @@<Page.Resources><converters:BooleanToVisibilityConverter x:Name="BooleanToVisibilityConverter"/><converters:InvertedBooleanConverter x:Name="InvertedBooleanConverter"/>+ <converters:NullToBooleanConverter x:Name="NullToVisible" IsInverted="True"/></Page.Resources><StackPanel Margin="0,0,0,16" Spacing="12">@@ -80,8 +81,14 @@<controls:CustomTextBoxHeader="{x:Bind ViewModel.Strings.OutputComparer}"- Height="50"AcceptsReturn="True"Text="{x:Bind ViewModel.OutputComparer, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />++ <muxc:InfoBar Severity="{Binding Severity, Mode=OneWay}"+ Message="{Binding Message, Mode=OneWay}"+ IsOpen="{Binding Mode=OneWay, Converter={StaticResource NullToVisible}}"+ DataContext="{x:Bind ViewModel.HashComparisonResult, Mode=OneWay}"+ IsClosable="False">+ </muxc:InfoBar></StackPanel></Page>diff --git a/src/dev/shared/SharedAssemblyInfo.cs b/src/dev/shared/SharedAssemblyInfo.csindex 10b703abb..6f8c30f64 100644--- a/src/dev/shared/SharedAssemblyInfo.cs+++ b/src/dev/shared/SharedAssemblyInfo.cs@@ -1,4 +1,4 @@-//------------------------------------------------------------------------------+//------------------------------------------------------------------------------// <auto-generated>// This code was generated by a tool.//