Skip to content

Respect disabled Avalonia name generator - #21804

Merged
MrJul merged 1 commit into
AvaloniaUI:mainfrom
mklts:FixNameGeneratorDisable
Jul 20, 2026
Merged

Respect disabled Avalonia name generator#21804
MrJul merged 1 commit into
AvaloniaUI:mainfrom
mklts:FixNameGeneratorDisable

Conversation

@mklts

@mklts mklts commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes AvaloniaNameGeneratorIsEnabled=false for the Avalonia XAML name generator.

The property is still defined in Avalonia.Generators.props and passed to the source generator through CompilerVisibleProperty, and it is still read by GeneratorOptions. However, after the migration to the incremental source generator pipeline, the value was no longer checked, so setting:

<AvaloniaNameGeneratorIsEnabled>false</AvaloniaNameGeneratorIsEnabled>

did not actually disable the name generator.

This PR restores the missing check and filters out XAML inputs before parsing/generation when the generator is disabled.

Regression
This was introduced in:

fca45c1

Migrate AvaloniaNameSourceGenerator to IIncrementalGenerator (#19216)

Author: @maxkatz6
Author date: 2025-08-13T13:22:14-07:00

Before that commit, the old AvaloniaNameSourceGenerator had an explicit gate:

var options = new GeneratorOptions(context);
if (!options.AvaloniaNameGeneratorIsEnabled)
{
    return null;
}

During the migration to AvaloniaNameIncrementalGenerator, the option continued to be read by GeneratorOptions, but the actual enabled check was not ported to the new incremental pipeline.

Fix
The XAML input filter now returns false immediately when AvaloniaNameGeneratorIsEnabled is disabled:

if (!options.AvaloniaNameGeneratorIsEnabled)
{
    return false;
}

This prevents the name generator from parsing XAML files and from producing generated .g.cs files when disabled, matching the previous behavior.

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0067531-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added bug backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Jul 20, 2026
@MrJul
MrJul added this pull request to the merge queue Jul 20, 2026
Merged via the queue into AvaloniaUI:main with commit 6278eb7 Jul 20, 2026
11 checks passed
@MrJul MrJul added backported-12.1.x and removed backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants