Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support to export Avalonia UI axaml file #2587

Open
unofficialdev opened this issue Dec 26, 2021 · 5 comments
Open

Add Support to export Avalonia UI axaml file #2587

unofficialdev opened this issue Dec 26, 2021 · 5 comments

Comments

@unofficialdev
Copy link

It seems that in avalonia applications the axaml match file is compiled to c# code. is it possible to add support for outputting axaml interface files as it was originally?
Image 2

@unofficialdev unofficialdev added the Enhancement Areas for improvement label Dec 26, 2021
@siegfriedpammer
Copy link
Member

is it possible to add support for outputting axaml interface files as it was originally?

I guess so... rather, the question is: who will add it?

@unofficialdev
Copy link
Author

unofficialdev commented Dec 26, 2021

Do you have any workaround for this goal? i think we need something like baml decompiler

@unofficialdev unofficialdev changed the title Add Support to export Avalonia UI xaml file Add Support to export Avalonia UI axaml file Dec 26, 2021
@siegfriedpammer
Copy link
Member

siegfriedpammer commented Dec 26, 2021

For those interested in adding support for this:

  • Avalonia XAML is compiled to IL, no custom binary/XML format, so the integration into ILSpy's UI is somewhat tricky...

image

We could add support for the binary/XML mixture format in !AvaloniaResources and add the nodes for the individual Avalonia XAML files as child nodes to that node, just as we do now for .resources files.

  • We would strongly advise you to not use ILSpy's C# output as a starting point, but rather the ILAst, which is the respresentation we use for most decompilation transforms, which is only later translated to C#.
    The most important reason is that it is way simpler than C#'s AST and that it accurately preserves all conversions (there are no implicit conversions).
    Only boolean constants and enums will need to be resolved separately, however, the generated IL code looks very easy to translate, so this should not be a big problem. Again, please do NOT use a C# AST for this!

The BAML decompiler already uses that approach to resolve the connection ids back to x:Name and event handlers. See https://github.com/icsharpcode/ILSpy/blob/master/ILSpy.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs#L116-L200

Hope this helps!

If anyone is interested in contributing such a feature, please get in touch with me, so I can provide you with answers to your potential questions. Thanks!

@siegfriedpammer
Copy link
Member

Do you have any workaround for this goal? i think we need something like baml decompiler

The workaround is manually translating ILSpy's output, sorry.

@christophwille
Copy link
Member

See also issue icsharpcode/AvaloniaILSpy#70 in AvaloniaILSpy repo.

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

No branches or pull requests

3 participants