AGENT SKILL

testfx-localization-validation

Validate generated TestFx localization catalogs, resource IDs, placeholders and locked tokens. Use for RESX/XLF changes, OneLoc PRs, localization build failures, duplicate targets or units, and orphaned translation entries.

License 许可
MIT
所属仓库
microsoft/testfx
最近更新
2026-11-14
Stars
★ 1.1k
Forks
315

01 前言 Front Matter

name
testfx-localization-validation
description
Validate generated TestFx localization catalogs, resource IDs, placeholders and locked tokens. Use for RESX/XLF changes, OneLoc PRs, localization build failures, duplicate targets or units, and orphaned translation entries.

03 SKILL.md 正文

TestFx localization validation

Run from the repository root with Python 3.12 or newer; no third-party packages or .NET build are needed for the guard:

python .github\scripts\test_check_localization.py
python .github\scripts\check_localization.py

On Linux/macOS use / in command paths. The standalone check-localization.yml workflow runs the same commands on localization PRs. The guard is read-only. Exit codes are 0 for clean, 1 for catalog findings, and 2 for invocation/discovery errors (including no catalogs).

Runtime choice

Python is a measured exception to the preference for PowerShell when there is no performance, feature or security impact. On Windows with Python 3.12.10 and PowerShell 7.6.6, nine interleaved warm-cache runs (including process startup) gave these medians:

Workload Complete Python guard PowerShell feasibility probe
All 364 catalogs / 19,695 units 1.830 s 3.686 s
Clean 13-locale fixture 0.272 s 0.825 s
Empty runtime startup 0.063 s 0.468 s

The dependency-free probe used .NET XML readers, cached neutral resources and ordinal IDs. It implemented only a subset of validation, not feature parity; it already exceeded the complete guard's runtime. Python is retained rather than accepting that regression or weakening the checks. These measurements are not a claim about every possible PowerShell implementation or other operating systems. A future port must demonstrate no performance regression and pass the committed regression suite, including case-sensitive IDs/tokens and literal/escaped placeholder semantics. Explicit .NET XML-reader security settings and DTD handling were independently exercised in the feasibility probe, not by the Python regression suite. A port must separately verify those settings and compare accepted XML-input profiles; passing the suite alone does not prove XML security parity.

Rules and limits

  • TestFx uses XLIFF 1.2 with the OASIS namespace and a relative file original pointing to the neutral RESX. Resolve it relative to the catalog, not the project or repository. Do not confuse locale cs (Czech) with a C# file.
  • The XLIFF 1.2 transitional schema requires one direct source and permits zero or one direct target per trans-unit. Do not require a target to exist. Targets inside alt-trans are alternatives, not duplicates. Groups are legal. Unit IDs are unique within a file across trans-unit and bin-unit, not globally across files.
  • Generated units must correspond to neutral string resource IDs, and their source text must match the neutral value exactly. When the neutral comment is nonempty, a note must match it exactly. Match XliffTasks' RESX exclusions: typed/binary entries, designer names (>>..., *.LayoutSettings), whole-value {Locked} comments, and empty/whitespace values do not require units. Additional notes are legal. An absent target or empty unfinished target is allowed; unfinished translations are not evidence of a structural defect.
  • Numeric composite-format argument indices must be preserved; reordering, repetition, alignment and format specifier changes are not automatically translation defects. Escaped braces are supported. Named templates such as {tfm} and literal JSON are not assumed to be .NET composite formats. When source text is not unambiguously a composite format, manually check any embedded numeric placeholders. This is not a complete String.Format parser.
  • Every {Locked="..."} token must occur verbatim in the neutral value and in a nonempty/completed target. Matching is case-sensitive and substring-based. The guard checks presence, not grammar or a word's translatability. Manually check for collisions with other words in the same value: const also matches constant. Prefer the longest unambiguous invariant token. Lock punctuation only when invariant or necessary to disambiguate.
  • This is a focused guard, not a full XSD validator or translation-quality review. Inline XLIFF codes require producer-specific rendering and are reported for manual handling instead of silently flattened. Do not invent new bans on otherwise legal XLIFF solely to make the checker pass.

Diagnose and repair at the authoritative source

Catalog-derived findings are grouped by neutral file, resource ID and defect, with every affected catalog path listed. Findings about the neutral RESX itself (XML/root/ID/value/locked-source errors) are emitted once for that file without listing its referencing catalogs. Treat one bad resource copied across 13 locales as one root cause, not 13 independent review requests.

The default command audits the entire current checkout, including tracked and non-ignored new catalogs. A finding is not automatically introduced by the PR. Compare the same check on the PR base before attributing older drift to the author. Do not silently repair old entries, suppress failures with a broad allowlist, or assume removing an orphan from one locale repairs all catalogs. The initial repository baseline was clean; no grandfathered ID list is needed.

For developer-owned values, IDs or comments, edit the neutral RESX only. Regenerate with the owning project's UpdateXlf target, using the pinned repository SDK initialized by the build scripts. For example, on Windows:

.\build.cmd
.\.dotnet\dotnet.exe msbuild src\Platform\Microsoft.Testing.Platform\Microsoft.Testing.Platform.csproj /t:UpdateXlf -bl:artifacts\log\localization-update.binlog
python .github\scripts\check_localization.py

Use the corresponding project for adapter, framework, analyzer or extension resources. If DOTNET_INSTALL_DIR supplies the repo's pinned SDK, use that dotnet instead. Regeneration is authoritative for source text, IDs and notes; it does not prove that a translation is linguistically correct. Inspect the generated diff and run the affected project's normal build when assessing a localization build failure.

Never hand-edit generated XLF. For duplicate targets, bad translations, translated placeholders or locked tokens in a OneLoc submission, route the grouped diagnostics to the OneLoc producer/maintainers and request a corrected generated submission. Regenerate developer-owned source metadata as appropriate; do not fabricate translated text or assume UpdateXlf repairs upstream translation quality. Re-run the guard on the corrected output.

04 同仓库更多 Skills

microsoft
microsoft/testfx

dotnet-breaking-changes

Use before changing .NET/C# code whose callers you do not control: a NuGet library, or a repo with PublicAPI.Shipped/Unshipped.txt, ApiCompat, multiple TargetFrameworks, InternalsVisibleTo, or generated (.g.cs) partials. Green builds miss silent breaks from optional parameters, parameter names, sealing, const values, nullability, and #if. USE FOR: "without breaking existing callers"; adding a public method, overload, optional parameter, or interface member to a shipped library; renaming a public method or an internal helper a friend assembly uses; consolidating duplicated logic; changing a signature, nullability, default, or attribute; adding a target framework; RS0016/RS0017 or ApiCompat errors; "is this PR breaking?". For a rename, extract, or merge, also invoke csharp-refactoring. DO NOT USE FOR: an executable whose callers all live in one project; renaming a local variable or private member, even in a shipped library; formatting; framework/SDK/NuGet upgrades (use dotnet-upgrade).

★ 1.1k
microsoft
microsoft/testfx

testfx-test-value-evidence

Apply the vendored test-value-evidence skill with TestFx toolchain, assertion, parallel-safety, packed-consumer, and review conventions. Use when implementing or reviewing behavior-changing TestFx PRs or commits, including source-only changes.

测试与质量
★ 1.1k
microsoft
microsoft/testfx

testfx-parallel-safety-preflight

Check concurrency and isolation before implementing or refactoring TestFx tests, lifecycle code, helpers, shared-state declarations, or production paths those tests exercise. Use before narrowing DoNotParallelize or ResourceLock, changing parallelization settings, or introducing asynchronous workers; repeat against the final diff.

★ 1.1k
microsoft
microsoft/testfx

testfx-acceptance-validation

Validate TestFx shipping paths and capable CI execution using packed consumers, package/cache provenance, exact exits and artifacts, and selected-versus-executed test evidence. Use for acceptance regressions, package/MSBuild/launcher/protocol changes, or skipped-only CI results; not for unrelated unit-only or documentation changes.

测试与质量
★ 1.1k
microsoft
microsoft/testfx

session-delivery-hygiene

Gate local-session scope, persistent delivery, live PR state, integration provenance, and owned cleanup. Use before implementing guidance changes, changing or pushing PR work, diagnosing package/output mismatches, or handing off implementation.

★ 1.1k
microsoft
microsoft/testfx

post-release-activities

Systematic activities that need to be performed after a release is done.

★ 1.1k