rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.92k stars 301 forks source link

Test module does not work with protected projects #354

Closed FlorianChevassu closed 9 years ago

FlorianChevassu commented 9 years ago

Hello !

First, let me say that I am impressed by the work you're doing ! I do not particularly like coding in VBA, but I think your addin will help me a lot !

I am testing your addin to see if I can use it in my everyday work. We use some proprietary addins which VBA project is protected by a password. When these addins are loaded, the Rubberduck addin does not work anymore. In particular the UnitTests part. I think you try to parse the protected modules, which throws a COM exception that is not handled.

If you have any question, or cannot reproduce the bug, let me know !

Keep up the good work !

Florian

rubberduck203 commented 9 years ago

Hi @FlorianChevassu! Thank you for the kind words.

What version of Rubberduck are you using? Per #289, this issue was resolved in version 1.21. Also, which Host Application are you using (Word, Excel, etc.). Unit testing is not yet supported in all of the Office Applications.

cc: @retailcoder

rubberduck203 commented 9 years ago

311 is also related.

rossorp commented 9 years ago

I too have this problem with the Test Explorer not opening, I just couldn't work out what the cause was until I saw this. Reading that the issue may be caused by protected modules, and realising that I had the Solver Add-In activated (with its associated protected project listed in the Project Explorer), I unloaded the Solver Add-In and now the Test Explorer opens for me.

I am running Excel 2010 (x86) on Windows 7 (x64) with build 1.21.5553.34023 of Rubberduck.

rubberduck203 commented 9 years ago

I don't think this is an actual parser issue and is not a duplicate of the other issues I mentioned. I suspect there is a similar snippet as this somewhere that isn't catching the exception. (Or possibly even a different exception being thrown here.)

    public void SynchronizeEngineWithIDE()
    {
        try
        {
            _testEngine.AllTests = this.VBE.VBProjects
                            .Cast<VBProject>()
                            .SelectMany(project => project.TestMethods())
                            .ToDictionary(test => test, test => _testEngine.AllTests.ContainsKey(test) ? _testEngine.AllTests[test] : null);

        }
        catch (ArgumentException)
        {
            System.Windows.Forms.MessageBox.Show(
                "Two or more projects containing test methods have the same name and identically named tests. Please rename one to continue.",
                "Warning", System.Windows.Forms.MessageBoxButtons.OK,
                System.Windows.Forms.MessageBoxIcon.Exclamation);
        }
    }

Going around the parser speeds things up, but it means going around the "protected project" fix.

https://github.com/retailcoder/Rubberduck/blob/5bcdb171e5a55b895f0a00266d84c23491a71768/RetailCoder.VBE/UI/UnitTesting/TestExplorerDockablePresenter.cs

FlorianChevassu commented 9 years ago

Hi @ckuhn203 !

I'm running Rubberduck 1.21 on Excel 2010 32bits on win7 64bits, same as @rossorp !

rubberduck203 commented 9 years ago

Thanks all. We're mid stream on a few things right now, but we think we can hotfix this relatively soon. Keep an eye on this issue for updates.

rubberduck203 commented 9 years ago

This search represents potential issues to be fixed.

rubberduck203 commented 9 years ago

I expect to create and test the 32bit installer this evening.

retailcoder commented 9 years ago

HotFix is here: https://github.com/retailcoder/Rubberduck/releases/tag/v1.22

rossorp commented 9 years ago

Just installed the hotfix (x86 versions) and tested it and I am no longer having any issues with the Test Explorer and protected modules. Thanks for the rapid fix!

FlorianChevassu commented 9 years ago

Same as @rossorp ! Works great for me !

Thanks !

rubberduck203 commented 9 years ago

@rossorp @FlorianChevassu thanks for the bug report! Keep 'em coming. I hope you enjoy the add-in as much as I do.