add support for CreateSourceInfo in design window loader - #21972
Conversation
|
You can test this PR using the following package version. |
|
AvaloniaUI/Avalonia#21972 to be able to test the JumpToSource feature in Designer
| UseCompiledBindingsByDefault = bool.TryParse(useCompiledBindings, out var parsedValue) && parsedValue | ||
| UseCompiledBindingsByDefault = bool.TryParse(useCompiledBindings, out var parsedValue) && parsedValue, | ||
| CreateSourceInfo = bool.TryParse(createSourceInfo, out var parsedCreateSourceInfo) && parsedCreateSourceInfo |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
hm, I tested this with Rider, and Rider seems to use this legacy call site.
There was a problem hiding this comment.
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.
|
@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. |
|
@cla-avalonia agree |
Applies to all designer/runtime load paths now; newer VS and VS Code designers do not use DesignWindowLoader.
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
What does the pull request do?
This PR enables
XamlSourceInfocreation in the Design Previewer.Custom controls can already retrieve XAML source location information from control instances. However,
XamlSourceInfowas previously only generated for compile-time XAML and not for XAML loaded through theRuntimeXamlLoaderused 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
XamlSourceInfocurrently 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
ToJumpSourcetest inAvalonia.JumpToSourcework 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