Skip to content

feat: add Uno Linter spec and uno-lint prototype - #163

Merged
kazo0 merged 22 commits into
mainfrom
dev/vs/uno-linter
Nov 10, 2026
Merged

kazo0 merged 22 commits into
mainfrom
dev/vs/uno-linter

Conversation

@vatsashah45

@vatsashah45 vatsashah45 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Type

  • Feature
  • Documentation content changes

What is the current behavior?

The uno-platform-studio plugin ships skills that tell an agent how to use MVUX, navigation, the Toolkit and theming, but nothing verifies what the agent actually wrote. Agents drift back to hard-coded colors, cards drawn as rounded Borders, hand-drawn icons and UI logic in code-behind. An agent-built sample with SimpleTheme, Toolkit and MVUX enabled still hard-coded its whole palette on every page.

What is the new behavior?

Adds specs/001-uno-linter: a feature specification for a deterministic XAML and C# linter that checks agent-written code after each edit and names the platform control or resource to use instead. Same spec format as the other Studio repos (prioritized user stories, FR/SC numbering, brief and checklist). Ships through three surfaces: a plugin hook and CLI now, an MCP tool on uno.devserver next, a Roslyn analyzer for the C# rules later.

Adds tools/uno-lint, in four projects:

Project Target Holds
Uno.Lint.Core netstandard2.0 rules only: the C# rules (Roslyn 4.8), the catalog, shared predicates, suppression comments, the immutable model
Uno.Lint.Xaml net9.0 the six XAML rules as Uno.XamlParser Stage-1 fixers that only report, and UnoLintXaml (AddTo, IsWellFormed, Collect), the steps any XamlParser host such as Studio Live or Uno.AI calls
Uno.Lint.Host net10.0 the linter (folder walk, project context, .editorconfig with Roslyn semantics), the immutable LintReport, and the hook adapters for Claude Code and Codex
Uno.Lint.Cli net10.0 uno-lint lint, rules and hook, with no command-line framework
  • Ten rules in two profiles (recommended: HEX, TOKENTHEME, ICON, BUILTIN, RESPONSIVE, BINDVALUE; strict adds CARD, BACKBAR, CODEBEHIND, OVERLAY), gated on Toolkit, MVUX and Uno.Themes references, severities per rule and per path from .editorconfig, reasoned suppression comments counted per rule.
  • The hook reads the payload as UTF-8, reports only the lines an edit added (bugs first), never blocks, and is wired through a shell shim that stays silent when the tool is not installed.
  • 287 xunit tests, including the command line run in memory and the built tool run with raw UTF-8 on stdin. FINDINGS.md has the corpus results and per-rule verdicts; XAMLPARSER.md describes how the rules use the parser package.

Nothing is wired into the plugin yet, and Uno.Lint.Tool is not published; this PR is the spec plus the tool for review. Open questions are listed at the end of the spec.

PR Checklist

  • Documentation has been added/updated
  • Associated with an issue (internal tracker, linked in the PR conversation)

Additional Information

The repo's validate-plugin workflow runs claude plugin validate . at the root; tools/ and specs/ contain no plugin manifests so it is unaffected. .github/workflows/uno-lint.yml builds, tests, packs and installs the tool, then runs the hook end to end through the shim, on Ubuntu, Windows and macOS when tools/uno-lint changes. The .gitignore already excludes bin/ and obj/.

🤖 Generated with Claude Code

Adds specs/001-uno-linter, a feature specification for a deterministic
XAML and C# linter that verifies what an agent wrote, complementing the
skills that tell it what to write. Includes the spec, a brief, and the
requirements checklist in the same format as the other Studio repos.

Adds tools/uno-lint, the C# prototype: a netstandard2.0 rule library
(XDocument for XAML, Roslyn for C#) with nine rules in recommended and
strict profiles, .editorconfig severities, Toolkit gating, suppression
comments, a CLI with path, JSON and Claude Code hook modes, 32 xunit
tests, and FINDINGS.md with the first corpus run.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@vatsashah45 vatsashah45 self-assigned this Oct 1, 2026
@vatsashah45
vatsashah45 requested a review from kazo0 October 1, 2026 18:47
- Hook: take added lines from tool_response.structuredPatch (Write create =
  every line). Fallback diffs old_string/new_string and stays silent when
  new_string is missing or ambiguous, instead of blaming the first match.
- Dev-path skip matches whole folder names (Tests/, MyApp.Tests/), not
  "Probe"/"Harness" anywhere; the old test passed only via the file name.
- BUILTIN matches control names as PascalCase words (no more
  OperatingHoursView -> RatingControl, DiscardBanner -> Card).
- Palette/icon file exemptions match whole words of the file name, so
  ColorPickerPage, AuthTokenPage and LexiconPage are linted.
- HEX fires only on color properties, Setter and keyframe values
  targeting one, and color elements; Text="#404" is text.

46 new tests (78 total). Toolkit samples re-run: one new HEX hit, from a
page the old palette-name match had hidden.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@noknowscode noknowscode left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really solid prototype. I cloned the branch: clean Release build, 78/78 tests pass. The one-core-many-surfaces shape, .editorconfig severities, Toolkit gating, and the hook reporting only added lines (via structuredPatch) are all the right calls, and the port fixes real false positives from my PowerShell version.

Inline comments below. The bugs marked confirmed reproduce with a small probe project (Toolkit enabled, strict profile). Strategic points first:

  1. Analyzer reuse is overstated (FR-022). Roslyn analyzers can't do file IO (RS1035) and receive syntax trees plus AnalyzerConfigOptions from the compiler. Linter, EditorConfig and ProjectContext read the disk, and CSharpAnalyzer parses its own trees. The rule functions can be shared; each surface needs a host layer. Worth rewording before the three-surface plan gets sign-off.
  2. Suppressions need to be a metric. In my own hook transcripts the agent answered 15 of 32 hits with an allow comment and fixed only 8. SC-005 ("HEX drops to zero within one turn") is satisfiable by suppressing everything. Suggest counting suppressions per rule in the report and JSON.
  3. Pull one correctness rule into phase 1. Design Decision 5 already argues that bug rules earn trust. Launching an official Uno Platform linter with only style rules invites pushback; {Binding State.Value} or x:Bind against an MVUX model would carry it.
  4. HEX fix text assumes Uno.Themes (Assumption 3). In a Fluent-only app PrimaryBrush/SurfaceBrush don't exist, and HEX is in recommended. Needs a theme gate like the Toolkit one.

Housekeeping: the PR body says 32 tests (it's 78), the conventional-commits check is failing, and there's no CI job building or testing tools/uno-lint. I'd consider landing the spec here and moving the prototype to its own repo or adding a build/test job.

Open questions from my side: CARD stays strict until the chip/avatar/zero-radius cases are fixed; hook first, gated on measured dnx cold start; skill owners own the fix text (UX-004); TOKENTHEME at suggestion.

Comment thread specs/001-uno-linter/spec.md Resolved
Comment thread specs/001-uno-linter/spec.md Resolved
Confirmed bugs from the PR review, each with a regression test:
- .editorconfig section globs are honored per file (EditorConfig
  semantics), so CLI and a future analyzer read the same file alike
- suppression comments above a multi-line element reach attribute hits
- CornerRadius="0", circles, pills and chips are no longer cards
- StaticResource/ThemeResource aliases are not TOKENTHEME hits

Review requests:
- HEX covers named colors in XAML and Colors.X / Color.FromArgb in C#
- suppressions are counted per rule (Supp column, JSON suppressed)
- hook leads with the fix and no longer offers the allow comment
- JSON carries the fix text; fix text adapts to Uno.Themes / Toolkit
- first correctness rule: BINDVALUE (UNOL201) for {Binding State.Value}
  in MVUX projects, recommended profile
- TOKENTHEME ships at suggestion severity
- handler detection matches FR-008 (object + *Args, two parameters)
- hook-mode project context cached; bin/obj never walked
- Roslyn pinned to 4.8.0; CSharpFile accepts a compiler SyntaxTree
- CI job builds, tests and packs tools/uno-lint on Ubuntu and Windows

Spec, README and FINDINGS updated with the dnx measurement (400-570 ms
vs 100 ms installed), the host-layer wording for FR-022, a suppression
budget in SC-005, and the review's answers to the open questions.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@vatsashah45

Copy link
Copy Markdown
Contributor Author

Thanks for the review, Matthew. Everything marked confirmed is fixed in b4ef3db with a regression test each, and the strategic points are addressed as follows:

  1. Analyzer reuse (FR-022): reworded. Only the rule functions are shared; Linter, EditorConfig and ProjectContext are the CLI host. CSharpFile takes a compiler SyntaxTree, Roslyn is pinned to 4.8.0, and .editorconfig sections are now honored per file so the two hosts will agree on counts.
  2. Suppressions as a metric: counted per rule (Supp column, suppressed + suppressedFindings in JSON). The hook no longer offers the allow comment; it leads with the fix. SC-005 now carries a 10% suppression budget.
  3. Correctness rule in phase 1: BINDVALUE (UNOL201) is in: {Binding State.Value} outside a DataTemplate in MVUX projects, recommended profile. Zero hits on the two MVUX apps in the corpus (both bind states correctly), so it is unit-tested only for now.
  4. HEX fix text: gated on an Uno.Themes reference; Fluent-only apps get WinUI brush names.

Also: named colors and Colors.X / Color.FromArgb are HEX now (BrewHouse +23, all White; the Toolkit gallery +250 in demo pages), TOKENTHEME ships at suggestion, handler detection matches FR-008, hook-mode context is cached and never walks bin/obj, dnx is measured (400 to 570 ms vs 100 ms installed, so the hook ships with the installed tool), and .github/workflows/uno-lint.yml builds, tests and packs the tool on Ubuntu and Windows. Your four open-question answers are recorded in the spec. 110 tests pass.

Still open from your list: the ShadowContainer exemption, and whether the prototype stays in tools/ here or moves to its own repo once the hook ships. The failing conventional-commits check is the scope in 8929aa9 (fix(uno-lint):; commitsar rejects the hyphen), which needs a reword and force-push on this branch.

@kazo0 kazo0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at b4ef3db. Built Release locally and ran the tests (110/110 pass). Every bug in the inline comments was reproduced against the built CLI with a small fixture project. The design is right and the previous round was addressed carefully, but two of the "fixed in b4ef3db" claims hold only in single-file mode, and there is a design question worth settling before the XAML-side fixes.

Design question: reuse Uno.XamlParser for the XAML side?

Uno.XamlParser (NuGet Uno.XamlParser, net9.0) is already the XAML pipeline in Uno.AI generation and in Studio Live, where spec 041 (studio.live#1118, studio.live#1362) runs it after every agent XAML write and feeds the diagnostics back to the agent. That is this PR's hook surface, already in production.

Rule-level overlap: none. Its codes (XML0001 to SEM3301) are correctness and normalization: does it parse, is #abc canonical, is the enum value valid. The ten rules here are style and architecture and are new either way.

Host-level overlap: most of XamlAnalyzer's plumbing.

  • Stage 0/1 element model: ParentIndex, XamlPropertyKind (attribute / attached / property element), line+column, namespace scope, comments as text tokens. Replaces the XDocument ancestry, key and attached-property helpers.
  • IXamlSemanticVisitor is an observe-only extension point; XamlDiagnostic is the finding shape.
  • Stage 0 repairs the unbalanced tags agents write and reports XML1006, where XDocument.Parse throws today and the file is silently skipped.
  • The same visitor assembly registers into Studio Live / Uno.AI with one DI line. There, Stage 2 type resolution makes BUILTIN, CARD and OVERLAY type-exact instead of name-regex.

What it does not give, so the host layer here stays as is: .editorconfig per-code severity (its policy model gates fixes per stage, not diagnostics per code), suppression comments, project context, exit codes, hook attribution, and all C# rules. XamlMarkupExpression is raw text plus IsBindingLike, so BINDVALUE keeps its regex. Stage 2 needs a type resolver, which a CLI/hook does not have; the parser's own xamlparser CLI is a PackAsTool net10.0 tool that runs Stage 0+1 only, and that is exactly the shape uno-lint would keep. Nothing in the linted app needs wiring.

The constraint: FR-022 pins the rule library to netstandard2.0 so a phase 3 Roslyn analyzer can load it, and Uno.XamlParser is net9.0 only. The C# rules are unaffected. Since the Uno XAML generator already surfaces UXAML diagnostics into build and IDE, I'd drop the XAML rules from the analyzer goal and rewrite XamlAnalyzer as IXamlSemanticVisitor implementations in a small package that references Uno.XamlParser. Caveats: it is prerelease (0.10.0-dev.74), and the pipeline is not thread-safe (Studio Live serializes it with a semaphore), so directory mode needs one pipeline per worker.

This changes the fix order: the .editorconfig and Directory.Build.props bugs are host-layer and survive either path. The HEX/TOKENTHEME merge and the ThemeDictionaries exemption live in XamlAnalyzer and get rewritten if the parser changes, so I'd settle this before fixing those.

Confirmed bugs (details inline)

  1. Nested .editorconfig ignored in directory mode, honored in hook mode: CLI and hook disagree on the same file (SC-006).
  2. Directory.Build.props above the csproj never read: Toolkit/MVUX/Themes gates close depending on which folder is linted.
  3. HEX merged into TOKENTHEME keyed by line number: gating depends on formatting, allow hex dropped.
  4. Unkeyed children inside ThemeDictionaries flagged as HEX.
  5. App.xaml.cs lifecycle handlers reported as CODEBEHIND.

Lower severity (inline where there is a line)

  • Preamble dotnet_diagnostic.*.severity is honored; a Roslyn analyzer would not read it there.
  • Suppression lookbehind crosses element boundaries.
  • Dev-path skip only applies in directory mode, so the hook lints Tests/ files the CLI skips.
  • OVERLAY panel suffix catches RootPanel / ContentPanel.
  • C# HEX has no palette-file exemption, unlike XAML.
  • Path mode accepts any file; uno-lint notes.txt parses as C# and reports clean.
  • Directory mode reads every XAML twice when the project files leave a flag unset. Fine at 175 files, worth a note for larger solutions.

CI

  • Conventional-commits fails only on 8929aa9: scope uno-lint is hyphenated and commitsar rejects that in this repo. Reword, or rely on squash-merge.
  • The validate-plugin failure (skills/uno-testing/SKILL.md mirror drift) is already on main; this branch's mirror is in sync. Not this PR's to fix.

Docs and nits

  • "nine rules" in User Story 2 scenario 3, FR-012 and FINDINGS.md; there are 10. FR-012's recommended list omits BINDVALUE while FR-023 includes it. The PR body also lists nine. Key Entities "Project context" omits MVUX and Themes.
  • allow all is accepted by the suppression regex but documented nowhere.
  • Polyfills.cs is dead: nothing in src uses init or record.
  • 41 xUnit analyzer warnings (xUnit2029, xUnit2031) in the test project.

What holds up well: exact attribution from structuredPatch, the netstandard2.0 core with the compiler-supplied SyntaxTree constructor, suppression counted as a metric instead of offered as an exit, a regression test for every bug from the previous round, the CI job, and the measured dnx numbers that settled the distribution question.

vatsashah45 and others added 2 commits October 13, 2026 16:37
Blocking:
- nested .editorconfig files below the lint root are loaded in
  directory mode, and a single file resolves its chain from the
  project root, so the CLI and the hook agree on every file
- Directory.Build.props / Directory.Packages.props above the project
  root feed the Toolkit, MVUX and Themes gates in every mode

Bugs:
- the HEX/TOKENTHEME fold is keyed on the element and keeps the gating
  HEX finding with a single-theme note; allow hex suppresses it
- anything nested under a keyed resource inside ThemeDictionaries is
  exempt from HEX
- App.xaml.cs and Application subclasses are exempt from CODEBEHIND

Minor:
- preamble severity keys are ignored and reported
- suppression look-behind stops at the first non-comment line
- "panel" dropped from the OVERLAY suffix set
- C# color literals get the palette-file exemption
- non-source files are rejected with exit 2; dev-path skip applies to
  single files
- XAML is read once in directory mode

Nits: ten rules everywhere, BINDVALUE in FR-012, Key Entities list
MVUX and Themes, allow all documented, Polyfills.cs removed, xUnit
analyzer warnings fixed. 127 tests.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@vatsashah45

Copy link
Copy Markdown
Contributor Author

Thanks Steve. Round 2 is in ef43333; every item from your review has a regression test in ReviewRound2Tests.cs, 127 tests pass and the test project builds with zero analyzer warnings.

Blocking, both host-layer, both survive a parser swap:

  1. Nested .editorconfig files below the lint root are loaded in directory mode, and single-file mode resolves the chain from the project root, so CLI and hook agree (SC-006).
  2. Directory.Build.props / Directory.Packages.props above the project root feed the Toolkit, MVUX and Themes gates in every mode.

Bugs: the HEX/TOKENTHEME fold is keyed on the element and now keeps the gating HEX warning with a single-theme note (GridWatch: 18 suggestions back to 18 warnings); anything nested under a keyed resource inside ThemeDictionaries is exempt; App.xaml.cs and Application subclasses are exempt from CODEBEHIND.

Minor: preamble severities ignored and reported; the suppression look-behind stops at the first non-comment line; panel dropped from OVERLAY; C# color literals get the palette-file exemption; non-source files exit 2; the dev-path skip applies to single files; XAML is read once in directory mode.

Nits: ten rules everywhere (spec, README, FINDINGS, PR body), BINDVALUE in FR-012, Key Entities list MVUX and Themes, allow all documented, Polyfills.cs removed, xUnit2029/2031 fixed.

On Uno.XamlParser: I agree with the split you describe (XamlParser hosts the XAML rules, Roslyn the C# rules, Linter stays the file-system and configuration layer) and kept this round's XAML changes small so they port. Before committing I would want the hook latency with the parser loaded measured against the 250 ms budget, and an owner for the prerelease package. Both are in the spec's open questions now. If you and Matthew want to see the delta, I can prototype the visitor host on a branch.

The conventional-commits failure is still only 8929aa9; the validate-plugin failure is main's mirror drift.

@Jen-Uno Jen-Uno changed the title feat: add Uno Linter spec and uno-lint prototype ♥️ feat: add Uno Linter spec and uno-lint prototype Oct 14, 2026
vatsashah45 and others added 2 commits October 14, 2026 16:03
Adds an experimental XAML host on Uno.XamlParser 0.10.0-dev.74 behind
--xaml-engine xamlparser, owning HEX and CARD:

- IXamlEngine in the netstandard2.0 core: an engine owns some rules,
  the built-in XDocument path runs the rest, no core dependency on the
  net9.0 parser
- RuleLogic: color, key and geometry predicates shared by both hosts
- Uno.Lint.Xaml: Stage 0 repairs on, Stage 1 fixers off, rules over
  the Stage-1 node model; partial reads are linted up to the stop
- repaired, partial and line-shifted counts in text and JSON output

Measured: identical findings on the five-app corpus (489/489), 7 of 7
broken-markup fixtures linted where the built-in host skips them, hook
273 ms with JIT and 194 ms with ReadyToRun. Write-up and upstream API
findings in tools/uno-lint/XAMLPARSER-SPIKE.md. 141 tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The six XAML rules (HEX, TOKENTHEME, ICON, CARD, BACKBAR, BINDVALUE)
are now Uno.XamlParser Stage-1 fixers that only report, registered
through SemanticFixerTypes, plus one stream visitor for element text.
UnoLintXamlRules.AddTo(options) adds them to any XamlParser pipeline,
so Studio Live and Uno.AI can enable them with one call.

The XDocument reader (XamlAnalyzer) is removed. uno-lint keeps what
XamlParser does not do: the C# rules on Roslyn, .editorconfig
severities, profiles, project gates, suppressions, the hook and output.
The CLI registers XamlParserEngine as the XAML host; --xaml-engine is
gone.

Measured against the XDocument reader on the five-app corpus: identical
findings and info counters, except six false positives removed
(<SolidColorBrush x:Key="Red"> flagged on its key). Malformed agent
markup is linted (8 of 8 fixtures). Hook 227 ms JIT, 185 ms ReadyToRun.

Works around a parser bug: the quote-repair sanitizer corrupts valid
XAML whose element text contains ":/" (ms-appx:///, http://), so
sanitizers run only on files that are not well-formed. This and nine
other parser issues are listed in tools/uno-lint/XAMLPARSER.md.
140 tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vatsashah45

Copy link
Copy Markdown
Contributor Author

Following the review and the 2026-10-14 call with Carl: the XAML side now runs on Uno.XamlParser. Two commits added, f867e67 (spike) and 8ebfd7f.

What changed

  • All six XAML rules are Uno.XamlParser Stage-1 fixers that only report, registered through SemanticFixerTypes, plus one stream visitor for element text. Our XDocument reader is deleted.
  • UnoLintXamlRules.AddTo(options) adds the rules to any XamlParser pipeline, so Studio Live and Uno.AI can run them in the pass they already do.
  • uno-lint keeps the C# rules and the host: .editorconfig, profiles, project gates, suppressions, hook, output.

Measured against the old reader

Check Result
Five-app corpus identical findings and info counters, except 6 false positives removed (<SolidColorBrush x:Key="Red"> flagged on its key)
Malformed agent markup 8 of 8 fixtures linted, previously 1 of 8
Hook, one edit 227 ms JIT, 185 ms ReadyToRun
Tests 140

For @carldebilly: tools/uno-lint/XAMLPARSER.md lists ten issues found in 0.10.0-dev.74. The first affects every consumer: the quote-repair sanitizer rewrites valid XAML whenever element text contains :/ (ms-appx:///, http://), even under DiagnosticsOnly, and the reader stops there. uno-lint works around it by running sanitizers only on files that are not well-formed. Minimal repro is in the doc.

The spec's architecture section and FR-022 are updated: the XAML rules leave the netstandard2.0 analyzer goal (the XAML generator's UXAML diagnostics cover build and IDE), the C# rules keep it. A new open question asks who owns Uno.XamlParser while the hook depends on it.

@kazo0

kazo0 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Tracked in unoplatform/private#1210 (Uno Team Backlog, studio/agentic). Supersedes unoplatform/studio.live#3833, which is closed: the linter ships through the plugin hooks and CLI, not inside studio.live.

@kazo0 kazo0 changed the title ♥️ feat: add Uno Linter spec and uno-lint prototype feat: add Uno Linter spec and uno-lint prototype Oct 19, 2026

@carldebilly carldebilly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the XamlParser move: running the XAML rules inside the pipeline Studio already uses is the right call, and the Claude Code hook attribution holds up. I fed real-shaped Edit, MultiEdit and Write payloads (with and without structuredPatch, plus the old/new fallback) and every hit landed on the exact added line. Garbage, empty or mistyped stdin exits 0 silently. Release build is clean and 140/140 tests pass.

This round looked at three questions besides the code itself: the command surface, whether --hook works in agent harnesses other than Claude Code, and how the Uno.XamlParser host behaves outside the happy path.

1. Command surface: reuse a command framework instead of hand-rolling it

Program.cs re-implements argument parsing and validation (45-72), the usage/help text (10-31, also copied by hand into the README and FR-017), the exit-code contract (384-389), --list-rules (74-82) and the --json writer (263-332), and none of it is tested. Repl Toolkit (MIT, net10.0 like this CLI) gives all of that from one command graph: typed option binding with typo suggestions, generated help (--help --json|xml|yaml, per-command help, doc export), the same 0/1/2 exit-code defaults, structured output from a typed result, shell completion, an in-memory test harness, and UseMcpServer() for the MCP surface the spec plans next. Nothing has shipped yet, so switching now is free; once the plugin wires uno-lint --hook, the command line becomes a contract.

The hook fits too: as a hook route marked AsProtocolPassthrough(), the handler receives an IReplIoContext (input/output writers) instead of touching Console directly, framework diagnostics are kept off the protocol stream, and the same handler runs in-memory under the test harness, which closes the hook test gap noted inline. Conditions worth checking first: start from CoreReplApp (no runtime dependencies) and measure startup against the hook budget, and turn the banner off. Even if the MCP tool ends up hosted on uno.devserver, the main gain is the same: one immutable, typed LintReport rendered by text, JSON and MCP, which is what SC-006 needs.

2. Hook portability across harnesses

  • Claude Code: works, with gaps noted inline. The most serious one: on Windows, stdin is decoded with the console code page, so any non-ASCII path or text (an accented user folder, for instance) makes the hook go silent.
  • Codex CLI: the hook fires but is a silent no-op. Per the Codex hooks docs, Edit|Write matchers alias apply_patch, whose payload carries the patch in tool_input.command with no file_path. A payload built from the docs exits 0 with empty output. The output shape (hookSpecificOutput.additionalContext, systemMessage) would be accepted. spec.md:270 currently claims the hook ships the linter to Codex.
  • Copilot CLI / Gemini CLI (docs only, not run): the snippet does not carry over as-is (tool names edit/create, top-level additionalContext; Gemini reads timeout in milliseconds).
  • dnx variant: unsafe as written (see inline), and Uno.Lint.Tool is not on nuget.org, so both documented install paths fail today.

3. Uno.XamlParser host

The well-formed path and Stage-0 repair work, but UnoLintXamlRules.AddTo(options) is not the drop-in the docs describe: the HEX/TOKENTHEME dedupe, suppressions and the :/ sanitizer gate live only in XamlParserEngine, and ElementTextCapture is registered as a singleton with mutable per-stream state, so hosts must serialize calls. Line-shift detection depends on reflection over an internal property and is only ever tested in the not-shifted case. A duplicate attribute or an undeclared prefix (utu:) stops the reader and silently drops every later finding. On my machine a XAML hit took 333-433 ms (JIT), above the documented 227 ms.

Before merge (public repo)

  • XAMLPARSER.md links to and describes the internals of a repository that is not public (its build failure, internal types, its agent instructions). Please keep only package-observable behaviour and file the parser issues upstream.
  • Commit b23b88e carries a Claude-Session: URL, and the PR body's closing link points to a non-public tracker. Please strip both from the squash message.

Also worth a look (lower confidence)

  • FileKinds walks into symlinks/junctions; two self-links make the walk explode.
  • RegexOptions.Compiled everywhere, including one regex per .editorconfig section per run, costs startup inside the hook budget.
  • Uno.Lint.Xaml targets net10.0 while the parser is net9.0; a net9.0 host could not reference it.
  • No end-to-end hook step in CI, no macOS runner.
  • The context cache lives in the shared temp folder (/tmp on Linux), undocumented, with no bypass.
  • The hook filters by line even on files whose repair shifted lines, and lists findings out of line order.
  • x:Name/x:Key values are echoed verbatim into the agent's context; restrict to identifier-shaped values, especially for the MCP surface.
  • The hook's lead sentence frames BINDVALUE (a real bug) as a style pattern.
  • --list-rules: Recommended vs --profile recommended, no MVUX gate or severity column, ignores --json.
  • DOCTYPE handling is unverified: a fixture with an internal and a SYSTEM entity in a card Border's x:Name would settle it.

Summary

1 blocker, 5 high, 21 medium, 5 low (plus style nits folded into the low comments). Suggested order, so one more round should be enough: (1) structure: rules-only netstandard2.0 core, a net10 host with an immutable LintReport and per-harness hook adapters, the CLI on a command framework, async engine, reusable XAML post-processing; (2) hook: UTF-8 stdin, a Codex apply_patch adapter or a Claude-Code-only scope, a stderr line in the catch-all, exit 0 always in hook mode, a PATH guard, drop or pin dnx; (3) robustness: lone CR, no-project fallback, reparse points; (4) tests for the hook envelope, JSON shape and exit codes; (5) docs: private content, session-log material, a single latency figure, stale counts.

Comment thread tools/uno-lint/XAMLPARSER.md Resolved
Structure
- Uno.Lint.Core is rules only (netstandard2.0): C# rules, catalog,
  RuleLogic, suppression, immutable Finding/ProjectContext. The folder
  walk, .editorconfig, context cache, report and hook adapters move to a
  net10.0 Uno.Lint.Host. IXamlEngine and the static XamlEngines registry
  are gone; the host references the XAML project directly.
- Uno.Lint.Xaml targets net9.0 like the parser. XamlLintEngine is async,
  serialized with a SemaphoreSlim and cancellable. UnoLintXaml exposes the
  three steps another XamlParser host needs: AddTo, IsWellFormed and
  Collect (gating, HEX/TOKENTHEME hand-off without a private code,
  suppression, line order, info counters).
- The CLI is a command graph on Repl Toolkit: lint, rules, hook. Help,
  binding, structured output and 0/1/2 exit codes come from one
  definition; handlers return one immutable LintReport.

Hook
- Payload read as raw UTF-8 whatever the console code page.
- One adapter per harness: Claude Code (Edit, MultiEdit, Write) and Codex
  (apply_patch, several files, paths relative to cwd).
- Always exits 0: unknown options are ignored with a stderr note, any
  failure is one stderr line. Bugs are listed before patterns. Files whose
  XAML repair shifted lines are named instead of misattributed.
- A file outside any project is linted with an empty context and only
  its ancestors' .editorconfig, without walking its folder.
- The dnx variant is dropped; a sh shim with a PATH guard and a
  UNO_LINT_CLI override replaces it, matching MultiEdit too.

Robustness
- Lone CR and mixed line endings split like XmlReader and Roslyn; the
  suppression look-behind is clamped.
- The folder walk skips symlinks and junctions.
- `default` is accepted as a severity.
- Messages never echo an x:Name or x:Key that is not identifier-shaped;
  DOCTYPE files are not read and entities never expanded.
- Interpreted or source-generated regexes instead of compiled ones; one
  suppression regex per rule; the context cache moves to the user's
  local application data with --no-cache and UNO_LINT_NO_CACHE.

Tests and docs
- Tests regrouped by subject (202): hook envelope, Codex payloads, raw
  UTF-8 through the built tool, JSON shape pinned through Repl's test
  harness, CR-only files, line shifts, symlink loops, cache entries.
- CI adds macOS and an end-to-end hook step through the packed tool.
- XAMLPARSER.md keeps only package-observable behaviour; FINDINGS.md
  keeps corpus results and verdicts; one latency measurement with its
  machine and method, referenced everywhere else.

Corpus findings are identical to the previous build on all five apps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vatsashah45

Copy link
Copy Markdown
Contributor Author

@carldebilly thanks for the thorough round. Everything is in 8d5b881; each inline comment has its own reply. In your suggested order:

  1. Structure. Uno.Lint.Core is rules only (netstandard2.0). Uno.Lint.Xaml targets net9.0 like the parser and exposes AddTo / IsWellFormed / Collect. A net10.0 Uno.Lint.Host holds the linter, .editorconfig, the immutable LintReport and the hook adapters. The CLI is a Repl Toolkit command graph (lint, rules, hook), and the XAML engine is async.
  2. Hook. UTF-8 stdin. Adapters for Claude Code and Codex apply_patch. A stderr line in the catch-all. Always exit 0, unknown options included. A sh shim with a PATH guard and UNO_LINT_CLI. dnx dropped.
  3. Robustness. Lone CR and mixed endings. No-project fallback without a folder walk. Symlinks and junctions are not followed.
  4. Tests. The hook envelope, Codex payloads, raw UTF-8 through the built tool, and the JSON shape and exit codes through Repl.Testing. 202 tests, regrouped by subject.
  5. Docs.
    • XAMLPARSER.md is now package-observable only.
    • The changelog is out of FINDINGS.md, the stale counts and unverifiable figures are gone, and there is one latency figure, in the spec's Performance section.

From the summary list:

  • RegexOptions.Compiled. Gone everywhere: interpreted regexes in netstandard2.0, source-generated ones in net9/net10. Together with the restructure, the hook went from 468 ms to 158 ms median on the same machine (Xeon E-2288G, JIT, 340-line page).
  • CI. It now runs on macOS too. It packs and installs the tool, then runs the hook end to end through the shim, with and without the tool on PATH.
  • Context cache. Now under the user's local application data, documented, with --no-cache and UNO_LINT_NO_CACHE.
  • Hook attribution. It no longer attributes findings in a file whose repair shifted lines; it names the file as malformed instead. Findings come in file and line order.
  • Identifiers. x:Name / x:Key are echoed only when they look like identifiers.
  • BINDVALUE. Rules now have a category; the hook leads with bugs, then patterns.
  • rules. Lists category, lowest profile, gate (toolkit or mvux) and default severity, and honors --json.
  • DOCTYPE. Settled: a file with a document type declaration is not read at all (counted as unparsed), and neither an internal nor a SYSTEM entity is expanded. XamlEngineTests has your fixture.

Before merge:

  • The Claude-Session: trailer. Removed from the old commit's message. That rewrote the branch's history, hence the force-push; the trees are unchanged.
  • The private tracker link. Removed from the description. Steve's comment above still records it.

Corpus findings are identical to the previous build on all five apps (757 findings, same rule, file, line and message).

vatsashah45 and others added 8 commits October 19, 2026 23:08
- HEX treated any property of a color-named control as a color slot, so
  <ColorPicker Header="Red"/> was reported. A color slot is now a
  color-named property, or the To/From/By/Value of a color animation or
  keyframe (RuleLogic.IsColorProperty).
- TOKENTHEME only looked for a {ThemeResource} on Color, so
  <AcrylicBrush TintColor="{ThemeResource ...}"/> was reported. Any
  attribute now counts.

Same changes as the Uno.XamlParser.BestPractices rules, so the two
implementations agree. Corpus counts unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
0.10.0-dev.80 carries the fix for the sanitizer that rewrote valid
markup with ":/" in element text. uno-lint keeps running the sanitizers
only on malformed text, so a valid file is never rewritten; the docs
now describe that as a choice rather than a workaround. Corpus findings
are identical to the dev.74 build on all five apps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A folder run now gives each file the project, dev-path skip and
  .editorconfig chain a run on that file gives it, so the CLI and the hook
  agree: a subfolder run finds the project above it, a nested root = true
  stops the chain, and a nested uno_lint.profile applies below it only.
- Dev-path folders are counted from the solution or repository root, so a
  MyApp.Tests project folder is skipped from any start.
- Generated files are skipped in single-file runs too.
- Cloud-placeholder folders (OneDrive) are walked; only links are skipped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- HEX reports a literal written as a color property element
  (<SolidColorBrush.Color>, a <Color> inside one, a keyframe Value under a
  color target) once, with the TOKENTHEME hand-off, and skips label
  property elements such as <ColorPicker.Header>.
- The single-theme note only appears when TOKENTHEME would report.
- CARD reads Background, CornerRadius, Width and Height from property
  elements, counts Border.Child as content, ignores attached property
  elements, and leaves image clips (an ImageBrush background) alone.
- BACKBAR is decided per root element.
- BINDVALUE skips bindings with ElementName, RelativeSource or Source.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The look-behind now tracks comments across lines: an allow comment after
  an element covers that line only, and an allow line inside a multi-line
  comment counts.
- C# files take their lines from Roslyn, which also ends a line at NEL, LS
  and PS, so findings and allow comments agree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The hook notes allow comments an edit added even when that is all it
  added, names files that share a name by their path, and lints a file a
  patch names twice once.
- C# lines from the payload are mapped to Roslyn's when a file has NEL, LS
  or PS characters.
- A raw-string tool_input (freeform apply_patch) or a payload of another
  shape no longer throws.
- --profile=x, --profile:x and Repl's own options are not called unknown.
- --markdown prints the whole text report; the last format flag decides
  the output, as Repl does; lint --help names the path argument.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- FR-014/016/017/018 and the README describe per-file project and
  .editorconfig resolution, the comment scan and the hook notes.
- The performance table holds today's measurements; SC-001 is not met.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vatsashah45

Copy link
Copy Markdown
Contributor Author

Another review pass on the CLI and hook found the bugs below; all are fixed with a test each (239 tests, 0 warnings). Uno.XamlParser is now 0.10.0-dev.80 (7a2f25e).

Folder and file runs now agree (ba0226a). Every file gets its own project root, dev-path skip and .editorconfig chain, wherever the run starts:

  • lint App/Views finds App/App.csproj above it.
  • A nested root = true stops the chain in folder runs too.
  • A nested uno_lint.profile applies below its folder only.
  • MyApp.Tests is skipped from any start, because dev folders are counted from the solution or repository root.

XAML rules (21d0b2e):

  • A brush color written as a property element is one HEX finding with the single-theme note.
  • <ColorPicker.Header> is a label.
  • CARD reads property elements and leaves image clips alone.
  • BACKBAR is decided per root element.
  • BINDVALUE skips ElementName, RelativeSource and Source bindings.

Allow comments (0d75626):

  • A trailing allow comment covers its own line only.
  • An allow line inside a multi-line comment counts.
  • C# lines follow Roslyn, which also breaks at NEL, LS and PS.

Hook and CLI (d67dd34):

  • An edit that only adds allow comments is still noted.
  • Same-name files are told apart by path, and a file a patch names twice is linted once.
  • A freeform apply_patch payload no longer throws.
  • --profile=x is no longer called unknown.
  • --markdown prints the whole report.

CI (d3c4512) installs the exact package version the run packed.

Corpus: every finding on the five corpus apps is identical to the previous build, so FINDINGS.md stands.

Latency correction: the spec's 158 ms hook figure did not reproduce. Re-measured, the hook takes 381 ms, and 206 ms of that is process start with an empty payload. The Performance section now has these numbers and says SC-001 is not met; getting under 250 ms needs ReadyToRun per platform or a resident process, which is a decision for a follow-up.

🤖 Generated with Claude Code

@kazo0 kazo0 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 4b2743d, with the question "is this ready to land once unoplatform/uno.xamlparser#39 publishes". Release build is clean, 239/239 tests pass, the branch merges cleanly with main, and the seven review threads that are still current all have their fixes in the code (the suppression test was renamed in the regroup). The three previous rounds covered the XAML rules and the hook envelope well, so this pass went after the parts they did not probe: the suppression scanner's string handling, the project-locator boundary, .editorconfig glob parsing and the hook's option path. Each item below was reproduced against the built CLI from this branch unless it says otherwise.

Three I would fix before merge, even with the tool unwired and unpublished. Each either contradicts a claim in the description or produces a silent green run:

  1. Suppression.cs: a /* or <!-- inside a string literal ("image/*", "**/*.cs") opens a comment that never closes, so one allow comment suppresses every later hit in the file. This also skews the suppression metric SC-005 relies on.
  2. HookRunner.cs: an edit that only adds an allow comment is still silent. The description says d67dd34 fixed this; both tests include the hit's line in the patch, which is why they pass.
  3. ProjectLocator.cs: a .git ancestor counts as the solution root, so a project with no .sln under Dev/, Tests/ or similar is skipped entirely: 0 files, exit 0, no warning, in folder and hook mode alike.

Before the hook ships through the plugin (inline): a bad --profile value disables the hook silently with an unprefixed stderr line; a malformed glob in any .editorconfig aborts the run where Roslyn would ignore the section; dev-path skipping differs between folder and single-file mode when no project exists above the file; <UnoFeatures Condition=...> is not read and commented-out package references count as live; --no-cache <file> swallows the path.

Nits (inline): the context cache key ignores XAML xmlns changes, so a page that starts using the Toolkit keeps Toolkit rules off until a project file changes; blank lines do not count toward the three-line look-behind; UNO_LINT_NO_CACHE is case-sensitive; FINDINGS.md and the spec disagree on the false-positive list (five vs six).

After #39 publishes: bump the pin, drop the four workarounds (I verified the swap: −91/+9 lines, 238/238 tests pass) and update XAMLPARSER.md lines 16/23/62–65 and spec.md line 301. The three items above fit in that same commit. With that round done, I would be comfortable landing this as the staged spec-plus-tool the description scopes it to, with the pre-ship list tracked.

Comment thread tools/uno-lint/FINDINGS.md Resolved
Comment thread tools/uno-lint/XAMLPARSER.md Resolved
vatsashah45 and others added 6 commits November 9, 2026 19:51
- The comment scanner knows each language: C# string, verbatim, raw and
  character literals and XAML CDATA are code, so "image/*" or
  Text="/*" no longer opens a comment that hides every later hit.
  // and /* mean nothing in XAML.
- Blank lines count toward the three-line look-behind.
- A suppressed finding carries the line of its allow comment, and the
  hook notes an edit that adds only that comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Only a solution makes the folders above a project count toward the
  dev-path skip, and the climb stops at the repository root, so a
  solution-less app under Dev/ in a repository is linted.
- A file outside any project is counted from its own folder in folder
  and single-file runs alike.
- An .editorconfig section header that is not a valid glob matches
  nothing instead of failing the run.
- UnoFeatures is read with attributes (Condition); commented-out
  references and features are ignored.
- A single-file run adds the linted page's own namespaces to the cached
  context; UNO_LINT_NO_CACHE accepts 1, true, yes or on in any case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- In hook mode an unknown or missing --profile value is dropped with one
  uno-lint: line on stderr and the hook runs with its defaults, instead
  of Repl rejecting the command and leaving every edit unlinted.
- Repl reads the token after a bool flag as its value, so
  'lint --no-cache <file>' failed; a flag not followed by true or false
  now gets an explicit value. A test keeps the flag list in step with
  the lint command's bool options.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- FR-015 to FR-018 and new edge cases for this round's fixes.
- The spec's false-positive table lists the same five prototype
  differences as FINDINGS.md; both note the key-named HEX hit the move
  to Uno.XamlParser removed, measured against the earlier reader.
- README: hook option handling and the cache variable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
uno-lint is expected to move into the Uno Studio CLI, which brings its
own command handling, so the command line no longer depends on a
preview of Repl.Core.

- UnoLintCli replaces UnoLintCommands and CommandLine: one option table
  per command drives both parsing and the generated help. Flags take no
  value, so a path after a flag is always the path, without rewriting
  the arguments first.
- Errors are one uno-lint: line on stderr with exit code 2. The hook
  still exits 0 and notes unknown options and --profile values.
- Output is the text report, --json or --markdown; the last one wins.
  --output:FORMAT, --human, --yaml and --xml are gone.
- CliTests run the same entry point as Main in memory, and check that
  help and the README list every option.

The JSON, text and Markdown reports and the exit codes are
byte-identical to the Repl build on the five corpus apps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-context workarounds

uno.xamlparser#39 gives fixers the element's index, its text at the end tag and whether the call is a
re-run on a parent, and exposes the sanitized text on the read result. The text-capturing visitor, the
seen-positions set and the reflection read of the repaired text go; XamlRules reads the context instead.
XAMLPARSER.md lists what dev.87 fixed and keeps the two behaviors still worked around.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PZQ75idMW4YnrJut3PKrok
@kazo0

kazo0 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Pushed 15968f0 onto this branch now that unoplatform/uno.xamlparser#39 is merged and Uno.XamlParser 0.10.0-dev.87 is on NuGet.

  • Uno.Lint.Xaml.csproj: 0.10.0-dev.80 → 0.10.0-dev.87
  • Drops the fixer-context workarounds that [Hot Design] Inverted version of the flame icon #39 made unnecessary: ElementTextCapture, the open-element path + seen-positions set, the reflection read of the repaired text, and the local namespace bookkeeping. They are replaced by XamlSemanticFixerContext.CurrentElementIndex / CurrentElementText / IsReapplyingToParent, XamlStreamReadResult.SanitizedText, and the parser's XmlNamespaces / IsNamespaceDeclaration().
  • Removes the The_repaired_text_is_still_reachable test, since nothing is read by reflection any more.
  • XAMLPARSER.md updated to match (the fixed rows moved out of the workaround table into a "Fixed in dev.87" paragraph).

Verified against the published package: clean restore from nuget.org, 286/286 tests pass, and uno-lint lint output is byte-identical to the previous head on Crewline, the six pilot apps and a malformed-XAML probe in both profiles. 8 files, +21/−104.

@vatsashah45 feel free to squash or reword as you like.

@kazo0
kazo0 merged commit d218679 into main Nov 10, 2026
9 checks passed
@kazo0
kazo0 deleted the dev/vs/uno-linter branch November 10, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants