ILSpy icon indicating copy to clipboard operation
ILSpy copied to clipboard

Add Support to export Avalonia UI axaml file

Open andreyk6617 opened this issue 3 years ago • 5 comments

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

andreyk6617 avatar Dec 26 '21 11:12 andreyk6617

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?

siegfriedpammer avatar Dec 26 '21 11:12 siegfriedpammer

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

andreyk6617 avatar Dec 26 '21 12:12 andreyk6617

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 avatar Dec 26 '21 12:12 siegfriedpammer

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.

siegfriedpammer avatar Dec 26 '21 12:12 siegfriedpammer

See also issue https://github.com/icsharpcode/AvaloniaILSpy/issues/70 in AvaloniaILSpy repo.

christophwille avatar Dec 26 '21 15:12 christophwille