Skip to content

add support for CreateSourceInfo in design window loader - #21972

Merged
MrJul merged 3 commits into
AvaloniaUI:mainfrom
Unrealiter:DesignerSourceInfo
Aug 18, 2026
Merged

add support for CreateSourceInfo in design window loader#21972
MrJul merged 3 commits into
AvaloniaUI:mainfrom
Unrealiter:DesignerSourceInfo

Conversation

@Unrealiter

Copy link
Copy Markdown
Contributor

What does the pull request do?

This PR enables XamlSourceInfo creation in the Design Previewer.

Custom controls can already retrieve XAML source location information from control instances. However, XamlSourceInfo was previously only generated for compile-time XAML and not for XAML loaded through the RuntimeXamlLoader used by the Designer.

This PR makes source information available in the Designer as well. This allows custom libraries and tooling to implement features such as Jump to Source, for example:

https://github.com/Unrealiter/Avalonia.JumpToSource

Known limitation

For instances created from the XAML file currently open in the Designer, the returned XamlSourceInfo currently contains "runtimexaml0" as the filename instead of the path to the actual XAML file.

The line and offset information is correct.

For example, to make the ToJumpSource test in Avalonia.JumpToSource work with the Designer, I had to special-case "runtimexaml0" and determine the path of the currently active XAML file by other means.

Source information for controls originating from other resources/pages continues to contain the expected source information.

Improves issues

Improves #20524 for the Designer

@avaloniaui-bot

Copy link
Copy Markdown

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

@cla-avalonia

cla-avalonia commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator
  • All contributors have signed the CLA.

Unrealiter pushed a commit to Unrealiter/Avalonia.JumpToSource that referenced this pull request Aug 14, 2026
AvaloniaUI/Avalonia#21972
to be able to test the JumpToSource feature in Designer
Comment thread src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs Outdated
Comment on lines +48 to +51
UseCompiledBindingsByDefault = bool.TryParse(useCompiledBindings, out var parsedValue) && parsedValue
UseCompiledBindingsByDefault = bool.TryParse(useCompiledBindings, out var parsedValue) && parsedValue,
CreateSourceInfo = bool.TryParse(createSourceInfo, out var parsedCreateSourceInfo) && parsedCreateSourceInfo

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.

Current VS/VSC previewer doesn't use this class anymore. And AFAIK these APIs are not accessible otherwise. Why do you need to enable CreateSourceInfo here?

Custom attribute from another file should be enough for the third-party tooling. So, these have information if source info is available or not.

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.

hm, I tested this with Rider, and Rider seems to use this legacy call site.

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.

I moved the evaluation into RuntimeXamlLoaderConfiguration, so by default the value is now read from LocalAssembly unless explicitly set.

With this change, I can also see XamlSourceInfo being generated in Visual Studio at design time.

I couldn't test this in VS Code, as I currently only see static images there and don't get any updates when, for example, hovering over elements.

@maxkatz6

Copy link
Copy Markdown
Member

@Unrealiter your GitHub account is different from Git commit account (@KimHenrikOtte). It's not really an issue for us, but it confuses CLA bot, as it expects @KimHenrikOtte to sign it (your @Unrealiter account has previously signed it already).

Can you force-push this commit under @Unrealiter account, or sign from @KimHenrikOtte? Thanks.

@KimHenrikOtte

Copy link
Copy Markdown
Contributor

@cla-avalonia agree

Applies to all designer/runtime load paths now; newer VS and VS Code designers do not use DesignWindowLoader.
@avaloniaui-bot

Copy link
Copy Markdown

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

@MrJul
MrJul enabled auto-merge August 18, 2026 14:43
@avaloniaui-bot

Copy link
Copy Markdown

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

@MrJul
MrJul added this pull request to the merge queue Aug 18, 2026
Merged via the queue into AvaloniaUI:main with commit bedb2ec Aug 18, 2026
9 checks passed
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.

6 participants