Hi,
I found an easily reproducible bug where SmartAssembly (latest version 8.1) creates an invalid class definition and crashes the application.
SmartAssembly renames the interface method but forgets to rename the implementation when I have a base class that "indirectly" implements the interface through a subclass.
It only requires 2 classes and 1 interface to reproduce the issue - check this out (sorry the code formatting in your forum engine blows up the code, so just pasting it in raw):
internal sealed class Notification : WindowBase, IWindow
{
}
internal abstract class WindowBase : System.Windows.Window
{
// This method will keep being named 'Fade' after obfuscation.
// Thus, this class no longer implements the interface it promises to implement and the application crashes when this class/type is loaded/used.
public void Fade()
{
Console.WriteLine("Hello world!");
}
}
internal interface IWindow
{
// This method definition will get renamed/obfuscated to something like '#...'
// However, the implementation in WindowBase will keep being named 'Fade'.
// This results in the 'Notification' type being invalid because it no longer implements IWindow and is thereby considered an 'invalid type'.
void Fade();
}
You can check the attached solution for a minimal reproducible example solution including a sample .saproj file.
The application works before obfuscation but crashes when being run after obfuscation. I have only tested it on .NET Framework 4.5.
I should note that it "works" in SmartAssembly 7.0.9 because that version seems to not rename the interface method 'Fade' (nor the implementation).
Of course it would be best if SmartAssembly was capable of renaming the method correctly in both WindowBase and IWindow.
UPDATE: It seems like the inheritance chain between WindowBase and System.Windows.Window is what breaks/confuses SmartAssembly. If I remove that inheritance chain, then it works as expected. However, in the real application this is obviously not possible. This clearly seems like a bug in SmartAssembly.
Best regards
Sol
The application works before obfuscation but crashes when being run after obfuscation. I have only tested it on .NET Framework 4.5.
UPDATE: It seems like the inheritance chain between WindowBase and System.Windows.Window is what breaks/confuses SmartAssembly. If I remove that inheritance chain, then it works as expected. However, in the real application this is obviously not possible. This clearly seems like a bug in SmartAssembly.