Skip to content

Component: Smrt.Tools.TokenGen

Canonical source: SmrtApps/src/Smrt.Tools.TokenGen/README.md (mirrored below)


Smrt.Tools.TokenGen

Public surface / entry points

  • CLI entry point: dotnet run --project SmrtApps/src/Smrt.Tools.TokenGen/Smrt.Tools.TokenGen.csproj

Configuration and operational data

  • Inputs are the checked-in JSON files under config/.
  • Outputs overwrite generated XAML dictionaries under SmrtApps/src/Smrt.UI/Themes/.

Observability and diagnostics

  • Emits logs using SmrtHub.Logging under the token-gen slug.

Support Bundle

  • Not applicable.

Overview & Responsibilities

  • Generates WinUI XAML ResourceDictionary files from the canonical JSON token and palette definitions.
  • Ensures Smrt.UI themes stay synchronized with design system updates (spacing, typography, motion, and color palettes).
  • Used by internal build/design workflows; not shipped to end users.

Inputs

  • config/tokens.json — non-color tokens (spacing, radius, opacity, motion, typography).
  • config/palettes.json — palette definitions for Light/Dark/HighContrast (keys map to Color.* resources).

Outputs

  • SmrtApps/src/Smrt.UI/Themes/Tokens/BaseTokens.xaml
  • SmrtApps/src/Smrt.UI/Themes/Palettes/Theme.<Name>.xaml (Light, Dark, HighContrast, etc.)

Usage

  1. From the repository root run dotnet run --project SmrtApps/src/Smrt.Tools.TokenGen/Smrt.Tools.TokenGen.csproj.
  2. The tool locates global.json, resolves the SmrtApps directories, and overwrites the generated dictionaries.
  3. Commit changes alongside design approval notes (see Themes/CHANGES-*.md).

Dependencies & Integrations

  • References SmrtHub.Logging to emit operational logs in the token-gen slug.
  • Relies on the JSON schema enforced by design tooling; extending schemas requires updating Program.cs and the downstream XAML consumers.

Validation Checklist

  • After regeneration, build Smrt.UI to confirm XBF compilation succeeds.
  • Smoke test consuming apps (HubWindow, Supervisor) to verify theme resources load without runtime exceptions.
  • Diff generated XAML to confirm expected token changes only.

Directory Map

  • Program.cs — token generator implementation.
  • config/ — JSON sources for tokens and palettes.
  • Smrt.Tools.TokenGen.csproj — .NET 8 console project.
  • bin/, obj/ — build output (safe to delete via dotnet clean).