#!/usr/bin/env bash # Lists resource keys with no caller in the C# sources. # # Written for the v1.12.0 cleanup and kept, because the count only stays # honest if it can be re-measured: every block of that cycle both revived # orphans and created new ones, so a list taken once is wrong by the next # commit. # # Reports rather than deletes. A key without a caller is a question -- was the # feature removed on purpose, or did it only lose its button? -- and the answer # is in the git history, not in this script. set -euo pipefail cd "$(dirname "$0")/.." for bundle in HellionStrings Language; do echo "=== ${bundle} ===" python3 - "$bundle" <<'PY' import sys, re, pathlib, xml.etree.ElementTree as E bundle = sys.argv[1] root = pathlib.Path("HellionChat") keys = [d.get("name") for d in E.parse(root / f"Resources/{bundle}.resx").getroot().findall("data")] sources = "\n".join( p.read_text(encoding="utf-8") for p in root.rglob("*.cs") if "obj/" not in p.as_posix() and "/bin/" not in p.as_posix() and "Designer.cs" not in p.name ) orphans = [k for k in keys if f"{bundle}.{k}" not in sources and f"nameof({k})" not in sources] print(f"{len(orphans)} of {len(keys)} keys have no caller") for k in sorted(orphans): print(f" {k}") PY done