Files
av-parser/src/AvParser.UI/ViewModels/CollectErrorViewModel.cs
T
Leonid PershinandClaude Opus 5 f8744c930a Remove the demo text-parsing domain
The scaffolding domain existed to prove the shell end to end before there was
anything real to put in it. There is now, so it goes - as CLAUDE.md promised it
would.

Gone: the two sample parsers, ITextParser, ParsedRecord, the parser catalog,
ParseViewModel and ParseView, their tests, and the settings key that remembered
which parser was last used. ParseError.LineNumber becomes Index, since for a
listing "line 42" was simply untrue, and the error keys move from Parse.Error.*
to Collect.Error.* now that parsing is not a concept here.

Kept: IParser<,>, ParseOutcome, ParseProgress and ParseError. The streaming
contract was always the general part - it was only ever the text-shaped closure
of it that was scaffolding.

Rendering the dashboard caught two keys that were referenced but never added
during the rename: the XAML was repointed and the resources were not. The parity
test could not see it, because it compares the two files against each other and
a key absent from both is consistent. That gap now has its own test, which reads
every {l:Loc} in the XAML and checks it resolves - a screenshot is too late and
too manual a way to find a missing string.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-13 22:23:52 +03:00

41 lines
1.5 KiB
C#

using AvParser.Core.Parsing;
using AvParser.UI.Localization;
using ReactiveUI;
namespace AvParser.UI.ViewModels;
/// <summary>One row of the collect error list, with its message translated.</summary>
/// <remarks>
/// Sources and the fetcher are part of the domain and produce English text plus a code. This resolves
/// <c>Collect.Error.{Code}</c> and falls back to the domain's own wording, so a code that has not
/// been translated yet still says something useful instead of showing a missing-key marker.
/// </remarks>
public sealed class CollectErrorViewModel(ParseError error) : ReactiveObject
{
/// <summary>The underlying error.</summary>
public ParseError Error { get; } = error ?? throw new ArgumentNullException(nameof(error));
/// <summary>1-based position of the offending item: a pasted line, or a place in a listing.</summary>
public int Index => Error.Index;
/// <summary>Translated message.</summary>
public string Text
{
get
{
if (Error.Code is not { Length: > 0 } code)
{
return Error.Message;
}
var template = Localizer.Instance.GetOrDefault($"Collect.Error.{code}", Error.Message);
return Error.Arguments.Count == 0
? template
: string.Format(Localizer.Instance.Culture, template, [.. Error.Arguments]);
}
}
/// <summary>Re-reads the translated message.</summary>
public void Refresh() => this.RaisePropertyChanged(nameof(Text));
}