Skip to content

Commit bee0f08

Browse files
authored
Merge pull request #2594 from comintern/next
Bypass VBA\Interop bug for broken references. Show Test Explorer if hidden when "Run all tests" selected from menu.
2 parents 368b120 + cd591ab commit bee0f08

File tree

6 files changed

+39
-26
lines changed

6 files changed

+39
-26
lines changed

RetailCoder.VBE/Root/RubberduckModule.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ public override void Load()
120120
.InSingletonScope();
121121

122122
Bind<IDockablePresenter>().To<TestExplorerDockablePresenter>()
123-
.WhenInjectedInto<TestExplorerCommand>()
123+
.WhenInjectedInto(
124+
typeof (RunAllTestsCommand),
125+
typeof (TestExplorerCommand))
124126
.InSingletonScope();
125127

126128
Bind<IDockablePresenter>().To<CodeInspectionsDockablePresenter>()

RetailCoder.VBE/UI/Command/RunAllTestsCommand.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ public class RunAllTestsCommand : CommandBase
1717
private readonly IVBE _vbe;
1818
private readonly ITestEngine _engine;
1919
private readonly TestExplorerModel _model;
20+
private readonly IDockablePresenter _presenter;
2021
private readonly RubberduckParserState _state;
21-
22-
public RunAllTestsCommand(IVBE vbe, RubberduckParserState state, ITestEngine engine, TestExplorerModel model)
22+
23+
public RunAllTestsCommand(IVBE vbe, RubberduckParserState state, ITestEngine engine, TestExplorerModel model, IDockablePresenter presenter)
2324
: base(LogManager.GetCurrentClassLogger())
2425
{
2526
_vbe = vbe;
2627
_engine = engine;
2728
_model = model;
2829
_state = state;
30+
_presenter = presenter;
2931
}
3032

3133
private static readonly ParserState[] AllowedRunStates = { ParserState.ResolvedDeclarations, ParserState.ResolvingReferences, ParserState.Ready };
@@ -76,6 +78,11 @@ private void RunTests()
7678
_model.ClearLastRun();
7779
_model.IsBusy = true;
7880

81+
if (_presenter != null)
82+
{
83+
_presenter.Show();
84+
}
85+
7986
stopwatch.Start();
8087
_engine.Run(_model.Tests);
8188
stopwatch.Stop();

RetailCoder.VBE/UI/UnitTesting/TestExplorerViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public TestExplorerViewModel(IVBE vbe,
4545

4646
_navigateCommand = new NavigateCommand();
4747

48-
_runAllTestsCommand = new RunAllTestsCommand(vbe, state, testEngine, model);
48+
_runAllTestsCommand = new RunAllTestsCommand(vbe, state, testEngine, model, null);
4949
_runAllTestsCommand.RunCompleted += RunCompleted;
5050

5151
_addTestModuleCommand = new AddTestModuleCommand(vbe, state, configService);

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,10 @@ private void SyncComReferences(IReadOnlyList<IVBProject> projects)
458458
for (var priority = 1; priority <= references.Count; priority++)
459459
{
460460
var reference = references[priority];
461+
if (reference.IsBroken)
462+
{
463+
continue;
464+
}
461465

462466
// skip loading Rubberduck.tlb (GUID is defined in AssemblyInfo.cs)
463467
if (reference.Guid == "{E07C841C-14B4-4890-83E9-8C80B06DD59D}")

Rubberduck.VBEEditor/SafeComWrappers/VB6/Reference.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ public Reference(VB.Reference target)
1212

1313
public string Name
1414
{
15-
get { return IsWrappingNullReference ? string.Empty : Target.Name; }
15+
get { return IsBroken ? string.Empty : Target.Name; }
1616
}
1717

1818
public string Guid
1919
{
20-
get { return IsWrappingNullReference ? string.Empty : Target.Guid; }
20+
get { return IsBroken ? string.Empty : Target.Guid; }
2121
}
2222

2323
public int Major
2424
{
25-
get { return IsWrappingNullReference ? 0 : Target.Major; }
25+
get { return IsBroken ? 0 : Target.Major; }
2626
}
2727

2828
public int Minor
2929
{
30-
get { return IsWrappingNullReference ? 0 : Target.Minor; }
30+
get { return IsBroken ? 0 : Target.Minor; }
3131
}
3232

3333
public string Version
@@ -37,17 +37,17 @@ public string Version
3737

3838
public string Description
3939
{
40-
get { return IsWrappingNullReference ? string.Empty : Target.Description; }
40+
get { return IsBroken ? string.Empty : Target.Description; }
4141
}
4242

4343
public string FullPath
4444
{
45-
get { return IsWrappingNullReference ? string.Empty : Target.FullPath; }
45+
get { return IsBroken ? string.Empty : Target.FullPath; }
4646
}
4747

4848
public bool IsBuiltIn
4949
{
50-
get { return !IsWrappingNullReference && Target.BuiltIn; }
50+
get { return !IsBroken && Target.BuiltIn; }
5151
}
5252

5353
public bool IsBroken
@@ -57,17 +57,17 @@ public bool IsBroken
5757

5858
public ReferenceKind Type
5959
{
60-
get { return IsWrappingNullReference ? 0 : (ReferenceKind)Target.Type; }
60+
get { return IsBroken ? 0 : (ReferenceKind)Target.Type; }
6161
}
6262

6363
public IReferences Collection
6464
{
65-
get { return new References(IsWrappingNullReference ? null : Target.Collection); }
65+
get { return new References(IsBroken ? null : Target.Collection); }
6666
}
6767

6868
public IVBE VBE
6969
{
70-
get { return new VBE(IsWrappingNullReference ? null : Target.VBE); }
70+
get { return new VBE(IsBroken ? null : Target.VBE); }
7171
}
7272

7373
public override bool Equals(ISafeComWrapper<VB.Reference> other)
@@ -89,7 +89,7 @@ public bool Equals(IReference other)
8989

9090
public override int GetHashCode()
9191
{
92-
return IsWrappingNullReference ? 0 : HashCode.Compute(Type, Name, Guid, FullPath, Major, Minor);
92+
return IsBroken ? 0 : HashCode.Compute(Type, Name, Guid, FullPath, Major, Minor);
9393
}
9494
}
9595
}

Rubberduck.VBEEditor/SafeComWrappers/VBA/Reference.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ public Reference(VB.Reference target)
1212

1313
public string Name
1414
{
15-
get { return IsWrappingNullReference ? string.Empty : Target.Name; }
15+
get { return IsBroken ? string.Empty : Target.Name; }
1616
}
1717

1818
public string Guid
1919
{
20-
get { return IsWrappingNullReference ? string.Empty : Target.Guid; }
20+
get { return IsBroken ? string.Empty : Target.Guid; }
2121
}
2222

2323
public int Major
2424
{
25-
get { return IsWrappingNullReference ? 0 : Target.Major; }
25+
get { return IsBroken ? 0 : Target.Major; }
2626
}
2727

2828
public int Minor
2929
{
30-
get { return IsWrappingNullReference ? 0 : Target.Minor; }
30+
get { return IsBroken ? 0 : Target.Minor; }
3131
}
3232

3333
public string Version
@@ -37,17 +37,17 @@ public string Version
3737

3838
public string Description
3939
{
40-
get { return IsWrappingNullReference ? string.Empty : Target.Description; }
40+
get { return IsBroken ? string.Empty : Target.Description; }
4141
}
4242

4343
public string FullPath
4444
{
45-
get { return IsWrappingNullReference ? string.Empty : Target.FullPath; }
45+
get { return IsBroken ? string.Empty : Target.FullPath; }
4646
}
4747

4848
public bool IsBuiltIn
4949
{
50-
get { return !IsWrappingNullReference && Target.BuiltIn; }
50+
get { return !IsBroken && Target.BuiltIn; }
5151
}
5252

5353
public bool IsBroken
@@ -57,17 +57,17 @@ public bool IsBroken
5757

5858
public ReferenceKind Type
5959
{
60-
get { return IsWrappingNullReference ? 0 : (ReferenceKind)Target.Type; }
60+
get { return IsBroken ? 0 : (ReferenceKind)Target.Type; }
6161
}
6262

6363
public IReferences Collection
6464
{
65-
get { return new References(IsWrappingNullReference ? null : Target.Collection); }
65+
get { return new References(IsBroken ? null : Target.Collection); }
6666
}
6767

6868
public IVBE VBE
6969
{
70-
get { return new VBE(IsWrappingNullReference ? null : Target.VBE); }
70+
get { return new VBE(IsBroken ? null : Target.VBE); }
7171
}
7272

7373
public override bool Equals(ISafeComWrapper<VB.Reference> other)
@@ -89,7 +89,7 @@ public bool Equals(IReference other)
8989

9090
public override int GetHashCode()
9191
{
92-
return IsWrappingNullReference ? 0 : HashCode.Compute(Type, Name, Guid, FullPath, Major, Minor);
92+
return IsBroken ? 0 : HashCode.Compute(Type, Name, Guid, FullPath, Major, Minor);
9393
}
9494
}
9595
}

0 commit comments

Comments
 (0)