Files
frameledger/tests/FrameLedger.Domain.Tests/DetectionFixtures.cs
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

94 lines
4.0 KiB
C#

// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FrameLedger.Domain.Detection;
namespace FrameLedger.Domain.Tests;
/// <summary>
/// Builders for the detection tests. Literals rather than a filesystem: the
/// evaluator does no I/O, which is exactly what makes the tri-state table
/// testable without building a directory tree for every row.
/// </summary>
internal static class DetectionFixtures
{
public static GameFileSnapshot Snapshot(
IEnumerable<string>? files = null,
IEnumerable<string>? dirs = null,
string exe = "C:/Games/Example/Game.exe",
string exeName = "Game",
string gameDir = "C:/Games/Example",
string? company = "Example Studios",
string? product = "Example Game",
string? fileVersion = "1.2.3.4",
string? productVersion = "++UE5+Release-5.3",
IReadOnlyDictionary<string, string>? siblingVersions = null,
IEnumerable<string>? needles = null,
IReadOnlyDictionary<string, string>? captures = null,
IReadOnlyDictionary<string, string>? manifest = null,
bool listingComplete = true,
IEnumerable<DetectionSignalType>? uncollected = null) =>
new()
{
ExePath = exe,
ExeNameWithoutExtension = exeName,
GameDirectory = gameDir,
RelativeFiles = files?.ToList() ?? [],
RelativeDirectories = dirs?.ToList() ?? [],
FileListingComplete = listingComplete,
PeCompanyName = company,
PeProductName = product,
PeFileVersion = fileVersion,
PeProductVersion = productVersion,
SiblingFileVersions = siblingVersions ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase),
MatchedStringNeedles = new HashSet<string>(needles ?? [], StringComparer.Ordinal),
StringsRegexCaptures = captures ?? new Dictionary<string, string>(StringComparer.Ordinal),
ManifestFields = manifest ?? new Dictionary<string, string>(StringComparer.Ordinal),
// manifest_field is uncollected by default because the store-manifest
// extractors are not built this phase. Stating it here means a test
// that expects a manifest answer has to say so deliberately.
UncollectedFacts = new HashSet<DetectionSignalType>(
uncollected ?? [DetectionSignalType.ManifestField]),
};
public static DetectionSignal Signal(DetectionSignalType type, string value, string? field = null) =>
new() { Type = type, Value = value, Field = field };
public static SignalGroup Group(SignalCombinator how, params DetectionSignal[] signals) =>
new() { Combinator = how, Signals = signals };
public static SignalGroup AnyOf(params DetectionSignal[] signals) =>
Group(SignalCombinator.Any, signals);
public static SignalGroup AllOf(params DetectionSignal[] signals) =>
Group(SignalCombinator.All, signals);
public static EngineRule Engine(string id, SignalGroup signals, VersionExtractor? version = null) =>
new() { Id = id, Name = id, Signals = signals, Version = version };
public static PlatformRule Platform(string id, SignalGroup signals) =>
new() { Id = id, Name = id, Signals = signals };
public static CapabilityRule Capability(string id, params string[] globs) =>
new()
{
Id = id,
Name = id,
Signals = AnyOf([.. globs.Select(g => Signal(DetectionSignalType.SiblingGlob, g))]),
};
public static DetectionRuleSet Rules(
IEnumerable<EngineRule>? engines = null,
IEnumerable<PlatformRule>? platforms = null,
IEnumerable<CapabilityRule>? capabilities = null) =>
new()
{
SchemaVersion = 2,
RulesVersion = "2026.08.1",
Engines = engines?.ToList() ?? [],
Platforms = platforms?.ToList() ?? [],
Capabilities = capabilities?.ToList() ?? [],
};
}