Skip to content

fix(hr): report suppressed source-generator errors on the operation - #24025

Merged
dr1rrb merged 1 commit into
masterfrom
dev/nr/hr-report-suppressed-generator-diagnostics
Aug 10, 2026
Merged

dr1rrb merged 1 commit into
masterfrom
dev/nr/hr-report-suppressed-generator-diagnostics

Conversation

@nickrandolph

Copy link
Copy Markdown
Contributor

Fixes #24022

Problem

#24012 suppresses source-generator errors for the EnC emit so a non-fatal generator error degrades to stale generated output instead of freezing hot reload — that part works. It reports them via diagnosticsReporter.ReportAnalyzerDiagnostics(generatorErrors), which routes to IReporter.Verbose. But a few lines later:

// Emit (EnC) diagnostics carry on every outcome of this branch; deltas are populated on Success only.
diagnostics = emitDiagnostics;

assigns outright, so the suppressed generator errors never reach the operation's diagnostics — the collection consumers actually read.

For a broken input outside the change set (the corrupt .resw case #24012 targets) that is harmless. For the file the user just edited it removes the only actionable message:

HR result: RudeEdit, Diagnostics: 1
DIAG: …/XamlCodeGenerator/MainPage_eb076510….cs(156,4):
      error ENC0020: Renaming method 'IMainPage_Bindings.UpdateResources()' requires restarting the application.

while the real error exists but is confined to the trace:

…/Presentation/MainPage.xaml(6,2): error UXAML0001: Name cannot begin with the '<' character,
   hexadecimal value 0x3C. Line 6, position 2.

So a user who mistypes XAML is told a generated IMainPage_Bindings member was renamed — code they never wrote and cannot see — instead of the line and column of their typo.

Fix

Carry the suppressed generator errors alongside the emit diagnostics:

diagnostics = emitDiagnostics.AddRange(generatorErrors);

The suppression still applies to the emit — hot reload keeps running, which is #24012's behaviour — but the diagnostics are no longer dropped from what is reported.

No dedup required, unlike the compilation-error FIXME a few lines below ("Needs dedup before fixing"): generator diagnostics never appear in compilation.GetDiagnostics(), so they cannot already be present in emitDiagnostics. The two sets are disjoint by construction.

Scope is already correct: generatorErrors comes from GetGeneratorErrorsAsync(auditedProjects, …), already limited to the change set's projects (spec 054), so this does not surface errors from projects the pass never touched.

The ENC diagnostic is retained, not replaced — consumers get both the rude-edit reason and the generator error that caused it.

Alternative considered

The issue suggested only suppressing diagnostics whose source file is outside the change set, which would separate the two cases at file granularity. I did not take that: it changes the suppression semantics #24012 deliberately chose, whereas this change only fixes the reporting, which is the actual defect. If you would rather have the finer-grained suppression, this PR does not conflict with it.

Verification

  • dotnet build src/Uno.HotReload/Uno.HotReload.csproj -c Debug — succeeds, 0 warnings, 0 errors.
  • Not verified end-to-end against the failing consumer test: that needs a dev SDK carrying this change. The expected effect is that operation.Diagnostics contains UXAML0001 and the ENC rude-edit diagnostic, where today it contains only the latter.

🤖 Generated with Claude Code

#24012 suppresses source-generator errors for the EnC emit so a non-fatal
generator error degrades to stale generated output instead of freezing hot
reload. It reports them to the console, but `diagnostics` is then assigned
`emitDiagnostics` outright, so they never reach the operation consumers see.

That loses the only actionable message for the file the user just edited.
Invalid XAML reports UXAML0001 among the generator errors, while the emit —
handed a degraded generated tree — reports a rude edit such as
ENC0020 "Renaming method 'IMainPage_Bindings.UpdateResources()' requires
restarting the application", naming generated code the user never wrote.
Consumers were shown only the misleading half.

Carry the suppressed generator errors alongside the emit diagnostics. No
dedup is required, unlike the compilation-error FIXME below it: generator
diagnostics never appear in compilation.GetDiagnostics(), so they cannot
already be present in emitDiagnostics. They are also already scoped to the
change set's projects via auditedProjects.

Fixes #24022

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings August 10, 2026 07:44

Copilot AI 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.

Pull request overview

This PR adjusts Uno’s hot-reload diagnostics propagation so source-generator error diagnostics that are intentionally suppressed for the EnC emit still flow into the HotReloadOperation diagnostics collection that consumers display.

Changes:

  • Combine suppressed source-generator error diagnostics with EnC emit diagnostics when populating the operation’s diagnostics.
  • Add explanatory in-code comments clarifying why generator diagnostics must be carried forward (especially for invalid XAML scenarios).

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Uno.HotReload/HotReloadManager.cs Resolved
@unodevops

Copy link
Copy Markdown
Contributor

Comment thread src/Uno.HotReload/HotReloadManager.cs Resolved
@dr1rrb

dr1rrb commented Aug 10, 2026

Copy link
Copy Markdown
Member

@Mergifyio backport release/stable/6.7

@mergify

mergify Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.7

✅ Backports have been created

Details

@dr1rrb

dr1rrb commented Aug 10, 2026

Copy link
Copy Markdown
Member

Approved: this is required for the UXAML error to be reported.

@dr1rrb
dr1rrb enabled auto-merge August 10, 2026 19:59
@dr1rrb
dr1rrb merged commit afe93db into master Aug 10, 2026
51 checks passed
@dr1rrb
dr1rrb deleted the dev/nr/hr-report-suppressed-generator-diagnostics branch August 10, 2026 20:00
dr1rrb added a commit that referenced this pull request Aug 11, 2026
…6.7/pr-24025

fix(hr): report suppressed source-generator errors on the operation (backport #24025)
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.

Hot reload: suppressing source-generator errors for the EnC emit also removes them from reported diagnostics (UXAML0001 replaced by ENC0020)

4 participants