Skip to content

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

Merged
dr1rrb merged 1 commit into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24025
Aug 11, 2026
Merged

dr1rrb merged 1 commit into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24025

Conversation

@mergify

@mergify mergify Bot commented Aug 10, 2026

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


This is an automatic backport of pull request #24025 done by Mergify.

#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]>
(cherry picked from commit 67e44b2)
@kazo0

kazo0 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@dr1rrb
dr1rrb merged commit 977dd75 into release/stable/6.7 Aug 11, 2026
46 of 47 checks passed
@dr1rrb
dr1rrb deleted the mergify/bp/release/stable/6.7/pr-24025 branch August 11, 2026 04:49
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