WPF issues
When decompiling WPF, please take care of code-behind files:
- [x] you can get the class name from the class attr in the xml file>
- [x] Name the code behind file after the xaml file and append
.cs, and place this file in the same folder as the xaml file. - [x] There is some auto-generated methods in such classes, marked with AutoGeneratd and/or NouUserCode attrs. Delete them.
- [x] There are also auto-generated fields corresponding to XAML tags, and there is a private field
private bool _contentLoaded;. Delete them. - [ ] The
Buid Actionfor App.xaml ispage, while it should beApplicationDefinition. - [ ] The
Buid Actionfor resources like images isEmbeddedResource, while it should beResource.
There is also a general behavior (not a WPF explosive) of creating all folders in one level with qualified names, which cause many errors with resource paths (as images, xaml, cshtml, etc). Please get rid of the namespace part, and nest folders.
Any doable part of these suggestion will save a lot of users time. Thanks
You and anyone else are very welcome to contribute this. The decompilation pipeline might need some adjustments / additional information passed in so that the code generated by XAML compilation can be transformed properly, if you want to dive into this and need some help, please feel free to ask questions.
Also possible to do (if assembly contains that information)
- [ ] Set a compile tool as
XamlIntelliSenseFileGeneratorfor .xaml files instead ofMSBuild:Compilenow
I'm sorry, probably I should create a separate issue thread for WPF issues with devexpress framework xaml files?
I tried to compile one of examples in DevExpress v21.2 library (DevExpress.StockMarketTrader.Wpf project), then opened .exe file in ILSpy and exported project. As I see, some decompiled xaml files have issues with compilation due to
- Some string parameters haven't additional quotes, for example I see an attribute
Foreground="{DXBinding Expr=CurrentPrice - PreviousPrice > 0 ? @r(greenBrush) : @r(redBrush)}"while original .xaml file hadForeground="{DXBinding Expr='CurrentPrice - PreviousPrice > 0 ? @r(greenBrush) : @r(redBrush)'}"
As I see by debugging ILSpy.BamlDecompiler project, originally single quotes were in XML document, but they were omitted later on rewrite passes. Also another product, dotPeek, decompiles .baml files without losing quotes here. Though, it have another problems with correct reconstruction of XAML markup.
- Sometimes tag inside tag is decompiled as attribute of some tag (why attribute, I don't know)
- Sometimes strange namespace declarations introduced in the middle of .xaml document, while original .xaml file haven't this namespace declarations
- Not necessary, but original file were pretty formatted (one attribute in a row), while decompiled .xaml file places all attributes of each tag in a single row
When decompiling WPF, please take care of code-behind files:
- [x] you can get the class name from the class attribute in the XML file
- [x] Name the code behind file after the XAML file and append
.cs, and place this file in the same folder as the XAML file.- [x] There is some auto-generated methods in such classes, marked with DebuggerNonUserCode, GeneratedCode, and/or EditorBrowsable attributes. Delete them.
- [x] There are also auto-generated fields corresponding to XAML tags, and there is a private field
private bool _contentLoaded;. Delete them.- [ ] The
Build Actionfor App.xaml ispage, while it should beApplicationDefinition.- [ ] The
Build Actionfor resources like images isEmbeddedResource, while it should beResource. There is also a general behavior (not a WPF exclusive) of creating all folders in one level with qualified names, which cause many errors with resource paths (as images, XAML, CSHTML, etc). Please get rid of the namespace part, and nest folders.Any doable part of these suggestion will save a lot of users time. Thanks
As of me upgrading from 8.1 or 8.0 to 8.2, it seems like it now it (with default settings) shows auto-generated methods marked with DebuggerNonUserCode, GeneratedCode, and/or EditorBrowsable attributes and doesn't delete auto-generated fields like _contentLoaded