Skip to content

Uno source generators: migrate heavy legacy ISourceGenerators to cache-friendly incremental pipelines #24204

Open

Description

@dr1rrb

Follow-up from the investigation on #24151.

Uno's heavy generators (XamlCodeGenerator, DependencyObjectGenerator, BindableTypeProviders*, RemoteControlGenerator, NativeCtorsGenerator, …) are legacy ISourceGenerator, which re-run fully on every compilation. Under Hot Reload every edit triggers a full re-generation + recompile → ~70 MB transient allocation per edit on a real app for a ~150 KB delta (measured).

Mini-repro (edit of a file unrelated to the generator, per edit):

Generator re-runs / edit alloc / edit
legacy ISourceGenerator 1 (full) ~0.6 MB
cache-friendly IIncrementalGenerator 0 ~0.03 MB (~20x less)
IIncrementalGenerator with .Combine(CompilationProvider) 1 (full) ~0.6 MB (== legacy)

Important caveat (perf != mechanical conversion). The win only materializes if the pipeline is cache-friendly: equatable value models, no Compilation/ISymbol captured in the pipeline hot path. Roslyn docs "Authoring a cache-friendly generator" and dotnet/roslyn Discussion #67469 confirm .Combine(CompilationProvider) defeats caching (the Compilation changes on every keystroke → full re-run). Note XamlCodeBehindGenerator already uses .Combine(context.CompilationProvider) — converting it naively would gain nothing.

Proposal: rewrite the hot-path generators as incremental with equatable extracted models; audit existing incremental generators for the CompilationProvider trap.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions