SmartAssembly crash bug (easily reproducible)

sol_ampsol_amp Posts: 5 New member
edited April 15, 2022 5:40PM in SmartAssembly
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
Tagged:

Answers

  • Hello Sol,

    Thank you for highlighting this issue, it's being tracked on our ref SA-2476, once addressed you'll be able to see that reference in the release notes. I should warn you that we're presently focusing on adding .Net 6 support to the .Net tools and that presently has priority.
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
  • Hello Sol,

    Thank you for your patience with us regarding issue SA-2476.

    Our development team have now reviewed the bug you have identified and highlighted to us alongside our current workload and available resources. Unfortunately, on this occasion this is not something they are able to provide a fix for.

    We do appreciate the effort our customers go to working with us to better our products, and so please do continue to highlight anything you find that needs our attention.

    We know this isn't the answer you were hoping for, thank you for trying to help us to improve our product.

    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
Sign In or Register to comment.