From 7b0f252306b03a5fe88fbe21ec051b8a8fd6e67c Mon Sep 17 00:00:00 2001 From: poli0981 <127664709+poli0981@users.noreply.github.com> Date: Mon, 16 Nov 2026 09:22:14 +0700 Subject: [PATCH] fix(app): the text to hash may be null Qodana's full analysis of main flagged `Text ?? string.Empty` as never null. The text box can set null when it is cleared, so the property is declared nullable instead of dropping the guard. Co-Authored-By: Claude Opus 5.5 --- src/HashTool.App/ViewModels/TextHashViewModel.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/HashTool.App/ViewModels/TextHashViewModel.cs b/src/HashTool.App/ViewModels/TextHashViewModel.cs index 0dd315f..7317423 100644 --- a/src/HashTool.App/ViewModels/TextHashViewModel.cs +++ b/src/HashTool.App/ViewModels/TextHashViewModel.cs @@ -48,7 +48,8 @@ public sealed partial class TextHashViewModel : ObservableObject private long _byteCount; [ObservableProperty] private LocalizationProxy _localization; - [ObservableProperty] private string _text = string.Empty; + /// The text to hash; the text box can set null when it is cleared. + [ObservableProperty] private string? _text = string.Empty; [ObservableProperty] private TextEncodingOption _selectedEncoding; [ObservableProperty] private LineBreak _selectedLineBreak = LineBreak.Lf; [ObservableProperty] private string _sizeText = string.Empty; @@ -91,7 +92,7 @@ public sealed partial class TextHashViewModel : ObservableObject /// The latest computation; tests wait for it. internal Task Pending { get; private set; } = Task.CompletedTask; - partial void OnTextChanged(string value) => Recompute(immediately: false); + partial void OnTextChanged(string? value) => Recompute(immediately: false); partial void OnSelectedEncodingChanged(TextEncodingOption value) => Recompute(immediately: true);