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 302 forks source link

Test Explorer Doesn't Run "Not Run Tests" from Run Menu #5493

Open SmileyFtW opened 4 years ago

SmileyFtW commented 4 years ago

Rubberduck version information Version 2.5.0.5432 OS: Microsoft Windows NT 10.0.18362.0, x64 Host Product: Microsoft Office x86 Host Version: 16.0.12730.20236 Host Executable: EXCEL.EXE

Description Clicking Run>Not Run Tests in Test Explorer Menu, no tests are run and the Run menu item is unresponsive.

To Reproduce Steps to reproduce the behavior:

  1. Have at least one test not run after a Rubberduck refresh
  2. With or without selecting a test, choose "Not Run Tests" in the Run Menu
  3. Observe Menu change for Run drop-down as disabled
  4. Observe Stop button on TE Menu as enabled, but does nothing
  5. To restore TE right-click on Run All Tests (the only option enabled for running tests)

Note: Refreshing RD doesn't restore the TE. Choosing either Ignore option does not restore the TE.

Expected behavior Test(s) would run.

Logfile RubberduckLog.txt

Vogel612 commented 4 years ago

Something curious in the logs is the NullReferenceException that shows up repeatedly when determining the CanExecuteIgnoreGroupCommand flag:

2020-05-06 16:32:48.3588;ERROR-2.5.0.5432;Rubberduck.UI.UnitTesting.TestExplorerViewModel;System.NullReferenceException: Object reference not set to an instance of an object.
   at Rubberduck.UI.UnitTesting.TestExplorerViewModel.CanExecuteUnignoreGroupCommand(Object obj) in C:\projects\rubberduck\Rubberduck.Core\UI\UnitTesting\TestExplorerViewModel.cs:line 278
   at Rubberduck.UI.Command.DelegateCommand.SpecialEvaluateCanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\DelegateCommand.cs:line 24
   at Rubberduck.UI.Command.CommandBase.<>c__DisplayClass14_0.<AddToCanExecuteEvaluation>b__0(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 37
   at Rubberduck.UI.Command.CommandBase.CanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 61;System.NullReferenceException: Object reference not set to an instance of an object.
   at Rubberduck.UI.UnitTesting.TestExplorerViewModel.CanExecuteUnignoreGroupCommand(Object obj) in C:\projects\rubberduck\Rubberduck.Core\UI\UnitTesting\TestExplorerViewModel.cs:line 278
   at Rubberduck.UI.Command.DelegateCommand.SpecialEvaluateCanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\DelegateCommand.cs:line 24
   at Rubberduck.UI.Command.CommandBase.<>c__DisplayClass14_0.<AddToCanExecuteEvaluation>b__0(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 37
   at Rubberduck.UI.Command.CommandBase.CanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 61

Another issue seems to be the RefactorExtractMethodCommand that uses a COM Wrapper when being constructed where the COM object has been detached:

16:38:12.9350;ERROR-2.5.0.5432;Rubberduck.UI.Command.Refactorings.RefactorExtractMethodCommand;System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
   at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
   at Microsoft.Vbe.Interop._VBComponent.get_CodeModule()
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBComponent.get_CodeModule() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBComponent.cs:line 23
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBComponent.ContentHash() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBComponent.cs:line 257
   at Rubberduck.Parsing.VBA.RubberduckParserState.IsNewOrModified(QualifiedModuleName key) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\RubberduckParserState.cs:line 1025
   at Rubberduck.UI.Command.Refactorings.RefactorExtractMethodCommand.SpecialEvaluateCanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\Refactorings\RefactorExtractMethodCommand.cs:line 39
   at Rubberduck.UI.Command.CommandBase.<>c__DisplayClass14_0.<AddToCanExecuteEvaluation>b__0(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 37
   at Rubberduck.UI.Command.CommandBase.CanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 61;System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
   at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
   at Microsoft.Vbe.Interop._VBComponent.get_CodeModule()
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBComponent.get_CodeModule() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBComponent.cs:line 23
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBComponent.ContentHash() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBComponent.cs:line 257
   at Rubberduck.Parsing.VBA.RubberduckParserState.IsNewOrModified(QualifiedModuleName key) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\RubberduckParserState.cs:line 1025
   at Rubberduck.UI.Command.Refactorings.RefactorExtractMethodCommand.SpecialEvaluateCanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\Refactorings\RefactorExtractMethodCommand.cs:line 39
   at Rubberduck.UI.Command.CommandBase.<>c__DisplayClass14_0.<AddToCanExecuteEvaluation>b__0(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 37
   at Rubberduck.UI.Command.CommandBase.CanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 61
2020-05-06 16:38:13.0151;ERROR-2.5.0.5432;Rubberduck.UI.Command.Refactorings.RefactorExtractMethodCommand;System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
   at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
   at Microsoft.Vbe.Interop._VBComponent.get_CodeModule()
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBComponent.get_CodeModule() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBComponent.cs:line 23
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBComponent.ContentHash() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBComponent.cs:line 257
   at Rubberduck.Parsing.VBA.RubberduckParserState.IsNewOrModified(QualifiedModuleName key) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\RubberduckParserState.cs:line 1025
   at Rubberduck.UI.Command.Refactorings.RefactorExtractMethodCommand.SpecialEvaluateCanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\Refactorings\RefactorExtractMethodCommand.cs:line 39
   at Rubberduck.UI.Command.CommandBase.<>c__DisplayClass14_0.<AddToCanExecuteEvaluation>b__0(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 37
   at Rubberduck.UI.Command.CommandBase.CanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 61;System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
   at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
   at Microsoft.Vbe.Interop._VBComponent.get_CodeModule()
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBComponent.get_CodeModule() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBComponent.cs:line 23
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBComponent.ContentHash() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBComponent.cs:line 257
   at Rubberduck.Parsing.VBA.RubberduckParserState.IsNewOrModified(QualifiedModuleName key) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\RubberduckParserState.cs:line 1025
   at Rubberduck.UI.Command.Refactorings.RefactorExtractMethodCommand.SpecialEvaluateCanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\Refactorings\RefactorExtractMethodCommand.cs:line 39
   at Rubberduck.UI.Command.CommandBase.<>c__DisplayClass14_0.<AddToCanExecuteEvaluation>b__0(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 37
   at Rubberduck.UI.Command.CommandBase.CanExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 61

Another issue is in the MemberAccessMayReturnNothingInspection that also produces a NullReferenceException:

16:38:36.2396;WARN-2.5.0.5432;Rubberduck.CodeAnalysis.Inspections.Logistics.Inspector;System.NullReferenceException: Object reference not set to an instance of an object.
   at Rubberduck.CodeAnalysis.Inspections.Abstract.MemberAccessMayReturnNothingInspectionBase.UsageContext(IdentifierReference reference) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\MemberAccessMayReturnNothingInspectionBase.cs:line 69
   at Rubberduck.CodeAnalysis.Inspections.Abstract.MemberAccessMayReturnNothingInspectionBase.IsResultReference(IdentifierReference reference, DeclarationFinder finder) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\MemberAccessMayReturnNothingInspectionBase.cs:line 35
   at Rubberduck.CodeAnalysis.Inspections.Abstract.IdentifierReferenceInspectionFromDeclarationsBase.<>c__DisplayClass5_0.<ResultReferences>b__0(IdentifierReference reference) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\IdentifierReferenceInspectionFromDeclarationsBase.cs:line 34
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Rubberduck.CodeAnalysis.Inspections.Abstract.IdentifierReferenceInspectionFromDeclarationsBase.DoGetInspectionResults(DeclarationFinder finder) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\IdentifierReferenceInspectionFromDeclarationsBase.cs:line 26
   at Rubberduck.CodeAnalysis.Inspections.Abstract.InspectionBase.GetInspectionResults(CancellationToken token) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\InspectionBase.cs:line 82
   at Rubberduck.CodeAnalysis.Inspections.Logistics.Inspector.RunInspection(IInspection inspection, ConcurrentBag`1 allIssues, CancellationToken token) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Logistics\Inspector.cs:line 175;System.NullReferenceException: Object reference not set to an instance of an object.
   at Rubberduck.CodeAnalysis.Inspections.Abstract.MemberAccessMayReturnNothingInspectionBase.UsageContext(IdentifierReference reference) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\MemberAccessMayReturnNothingInspectionBase.cs:line 69
   at Rubberduck.CodeAnalysis.Inspections.Abstract.MemberAccessMayReturnNothingInspectionBase.IsResultReference(IdentifierReference reference, DeclarationFinder finder) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\MemberAccessMayReturnNothingInspectionBase.cs:line 35
   at Rubberduck.CodeAnalysis.Inspections.Abstract.IdentifierReferenceInspectionFromDeclarationsBase.<>c__DisplayClass5_0.<ResultReferences>b__0(IdentifierReference reference) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\IdentifierReferenceInspectionFromDeclarationsBase.cs:line 34
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Rubberduck.CodeAnalysis.Inspections.Abstract.IdentifierReferenceInspectionFromDeclarationsBase.DoGetInspectionResults(DeclarationFinder finder) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\IdentifierReferenceInspectionFromDeclarationsBase.cs:line 26
   at Rubberduck.CodeAnalysis.Inspections.Abstract.InspectionBase.GetInspectionResults(CancellationToken token) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\InspectionBase.cs:line 82
   at Rubberduck.CodeAnalysis.Inspections.Logistics.Inspector.RunInspection(IInspection inspection, ConcurrentBag`1 allIssues, CancellationToken token) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Logistics\Inspector.cs:line 175

none of these errors explain the behaviour you're seeing, though. As such each of them should be put into a separate issue and solved as well...

SmileyFtW commented 4 years ago

FWIW, I just noticed this in the latest pre. I know it worked in the past, but I have installed several pre releases and not been doing any work in the TE for many of them so I don't know when it stopped working.