Files
poli0981andClaude Fable 5.2 1342979353 ci: Qodana - JetBrains' code analysis from a workflow of its own, and what its first run reported settled (D93) (#373)
* ci: Qodana - a workflow of its own from JetBrains' template, Qodana Community for .NET over FrameLedger.slnx (D93)

The first run: the linter in its Linux container, EnableWindowsTargeting passed
to it, no quality gate yet - what it builds and what it reports decides the rest.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* ci: Qodana's gate is zero problems, and the inspections this project argues with are off in .editorconfig, each with its reason (D93)

Pushed before the fixes on purpose: the run this starts has the settings and
none of the fixes, so it shows the gate failing on what is left.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* fix: what Qodana's first run reported, settled - about 400 fixes in 181 files, none changing behaviour; the documents (D93)

Redundant qualifiers, casts, using directives, nullable suppressions and unsafe
modifiers removed from the report's own positions; var for built-in types and
one-line block bodies brought to .editorconfig's style by dotnet format; every
XAML item template names its DataType and a binding that reached its page through
DataContext.ViewModel names the page's type; two unread fields, two overwritten
initialisers and an unused parameter removed; SpokenTextAutomationPeer no longer
assumes the base peer's name is a string.

docs/13_CI_CD.md §Qodana, CLAUDE.md, the wiki's workflow table, HANDOFF's
decisions index (D93) and the changelog entry.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 16:13:04 +00:00

120 lines
5.0 KiB
C#

// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Globalization;
using System.IO;
using System.Xml.Linq;
using FluentAssertions;
namespace FrameLedger.App.Tests;
/// <summary>
/// The generated accessor against the satellites the build produced: every key resolves in en, vi and ja
/// (a missing satellite would fall back to English silently, and this is the one place that would show), and
/// the accessor's key list is the resx's — the audit gate checks the same from the outside.
/// </summary>
[Collection(StringsCultureCollection.Name)]
public sealed class StringsTests
{
private static readonly string[] _cultures = ["en", "vi", "ja"];
[Theory]
[InlineData("en")]
[InlineData("vi")]
[InlineData("ja")]
public void EveryKeyResolvesToANonEmptyStringIn(string culture)
{
var ci = CultureInfo.GetCultureInfo(culture);
foreach (string key in Strings.Keys)
{
Strings.ResourceManager.GetString(key, ci).Should().NotBeNullOrWhiteSpace($"{key} in {culture}");
}
}
[Fact]
public void TheSatellitesAreReallyLoadedNotTheEnglishFallback()
{
string en = Strings.ResourceManager.GetString(nameof(Strings.Nav_Settings), CultureInfo.GetCultureInfo("en"))!;
string vi = Strings.ResourceManager.GetString(nameof(Strings.Nav_Settings), CultureInfo.GetCultureInfo("vi"))!;
string ja = Strings.ResourceManager.GetString(nameof(Strings.Nav_Settings), CultureInfo.GetCultureInfo("ja"))!;
vi.Should().NotBe(en, "vi/FrameLedger.resources.dll must be beside the assembly");
ja.Should().NotBe(en, "ja/FrameLedger.resources.dll must be beside the assembly");
_cultures.Should().HaveCount(3);
}
[Fact]
public void TheAccessorsKeysAreTheResxsKeys()
{
string resx = Path.Combine(RepoRoot(), "src", "FrameLedger.App", "Strings.resx");
string[] keys = XDocument.Load(resx).Root!.Elements("data").Select(d => (string)d.Attribute("name")!).ToArray();
Strings.Keys.Should().BeEquivalentTo(keys, "Strings.Designer.cs is generated from Strings.resx and committed; tools/resx-audit.ps1 fails on drift");
}
/// <summary>
/// beta.13: the culture collection's definition is the one bound — it is what takes these classes out of the parallel
/// phase — so a definition xUnit did not find would fail here rather than bring the races back silently.
/// </summary>
[Fact]
public void TheCultureCollectionIsBoundToTheDefinitionThatRunsItAlone() => TestContext.Current.TestCollection!.TestCollectionClassName.Should().Be(typeof(StringsCultureDefinition).FullName);
[Fact]
public void TheCulturePropertyOverridesTheThread()
{
CultureInfo? previous = Strings.Culture;
try
{
Strings.Culture = CultureInfo.GetCultureInfo("vi");
Strings.Nav_Settings.Should().Be("Cài đặt");
Strings.Culture = CultureInfo.GetCultureInfo("en");
Strings.Nav_Settings.Should().Be("Settings");
}
finally
{
Strings.Culture = previous;
}
}
/// <summary>
/// The owner's beta.3 screenshot: a Vietnamese UI whose consent dialog and refusal notices were
/// English. FrameLedger.Shared's Strings had no culture of its own, and the thread culture set during the async
/// start does not reach the dispatcher's later operations. <c>ApplyCulture</c> sets BOTH families explicitly.
/// </summary>
[Fact]
public void ApplyingTheUiLanguageSetsTheSafetyFamilyToo()
{
CultureInfo? app = Strings.Culture;
CultureInfo? safety = Shared.Strings.Culture;
CultureInfo thread = CultureInfo.CurrentUICulture;
CultureInfo? threadDefault = CultureInfo.DefaultThreadCurrentUICulture;
try
{
App.ApplyCulture("vi");
// The thread's culture is put back to English ON PURPOSE: the explicit culture must not depend on it.
CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en");
Shared.Strings.Culture.Should().Be(CultureInfo.GetCultureInfo("vi"));
Shared.Strings.Safety_HookingTurnedOff.Should().StartWith("Hooking đã được tắt");
Shared.Strings.Safety_Blocked_Toggle_Format.Should().StartWith("Hooking bị vô hiệu hoá");
Strings.Nav_Settings.Should().Be("Cài đặt");
}
finally
{
Strings.Culture = app;
Shared.Strings.Culture = safety;
CultureInfo.CurrentUICulture = thread;
CultureInfo.DefaultThreadCurrentUICulture = threadDefault;
}
}
private static string RepoRoot()
{
string? dir = AppContext.BaseDirectory;
while (dir is not null && !File.Exists(Path.Combine(dir, "FrameLedger.slnx")))
{
dir = Path.GetDirectoryName(dir);
}
return dir ?? throw new InvalidOperationException("FrameLedger.slnx not found above the test binary");
}
}