Skip to content

Commit 6dac808

Browse files
committed
Merge branch 'ReworkParseCoordinatorPart1Bugfix' into ReworkParseCoordinatorBugfixing
Incorporating bugfix.
2 parents 2db6457 + 22ec3a4 commit 6dac808

File tree

3 files changed

+19
-55
lines changed

3 files changed

+19
-55
lines changed

Rubberduck.Parsing/VBA/ComponentParseTask.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ public void Start(CancellationToken token)
101101
Cause = exception
102102
});
103103
}
104-
catch (OperationCanceledException)
104+
catch (OperationCanceledException exception)
105105
{
106-
// no results to be used, so no results "returned"
106+
//We return this, so that the calling code knows that the operation actually has been cancelled.
107+
var failedHandler = ParseFailure;
108+
if (failedHandler != null)
109+
failedHandler.Invoke(this, new ParseFailureArgs
110+
{
111+
Cause = exception
112+
});
107113
}
108114
}
109115

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,14 @@ private void ParseComponents(List<IVBComponent> components, CancellationToken to
242242

243243
parser.ParseFailure += (sender, e) =>
244244
{
245-
tcs.SetException(e.Cause);
245+
if (e.Cause is OperationCanceledException)
246+
{
247+
tcs.SetCanceled();
248+
}
249+
else
250+
{
251+
tcs.SetException(e.Cause);
252+
}
246253
};
247254
parser.ParseCompleted += (sender, e) =>
248255
{
@@ -257,7 +264,6 @@ private void ParseComponents(List<IVBComponent> components, CancellationToken to
257264

258265
private void ProcessComponentParseResults(IVBComponent component, Task<ComponentParseTask.ParseCompletionArgs> finishedParseTask)
259266
{
260-
finishedParseTask.Wait();
261267
if (finishedParseTask.IsFaulted)
262268
{
263269
//In contrast to the situation in the success scenario, the overall parser state is reevaluated immediately.
Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
2-
using System.Runtime.InteropServices;
3-
using System.Runtime.InteropServices.ComTypes;
2+
using System.ComponentModel;
43
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
54

65
namespace Rubberduck.VBEditor.SafeComWrappers.Office.Core.Abstract
@@ -16,59 +15,12 @@ public static string TypeName(this IControl control)
1615
{
1716
try
1817
{
19-
var dispatch = control.Target as IDispatch;
20-
if (dispatch == null)
21-
{
22-
return "Control";
23-
}
24-
ITypeInfo info;
25-
dispatch.GetTypeInfo(0, 0, out info);
26-
string name;
27-
string docs;
28-
int context;
29-
string help;
30-
info.GetDocumentation(-1, out name, out docs, out context, out help);
31-
return name;
18+
return TypeDescriptor.GetClassName(control.Target);
3219
}
3320
catch
3421
{
3522
return "Control";
3623
}
37-
}
38-
39-
[ComImport]
40-
[Guid("00020400-0000-0000-C000-000000000046")]
41-
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
42-
interface IDispatch
43-
{
44-
[PreserveSig]
45-
int GetTypeInfoCount(out int Count);
46-
47-
[PreserveSig]
48-
int GetTypeInfo(
49-
[MarshalAs(UnmanagedType.U4)] int iTInfo,
50-
[MarshalAs(UnmanagedType.U4)] int lcid,
51-
out ITypeInfo typeInfo);
52-
53-
[PreserveSig]
54-
int GetIDsOfNames(
55-
ref Guid riid,
56-
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)]
57-
string[] rgsNames,
58-
int cNames,
59-
int lcid,
60-
[MarshalAs(UnmanagedType.LPArray)] int[] rgDispId);
61-
62-
[PreserveSig]
63-
int Invoke(
64-
int dispIdMember,
65-
ref Guid riid,
66-
uint lcid,
67-
ushort wFlags,
68-
ref System.Runtime.InteropServices.ComTypes.DISPPARAMS pDispParams,
69-
out object pVarResult,
70-
ref System.Runtime.InteropServices.ComTypes.EXCEPINFO pExcepInfo,
71-
IntPtr[] pArgErr);
72-
}
24+
}
7325
}
7426
}

0 commit comments

Comments
 (0)