Skip to content

Commit adae41a

Browse files
committed
Fix version formatting, review comment.
1 parent 76cfd9a commit adae41a

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

Rubberduck.VBEEditor/VBERuntime/Settings/VBESettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public VbeSettings(IVBE vbe, IRegistryWrapper registry)
2626
{
2727
case DllVersion.Vbe7:
2828
case DllVersion.Vbe6:
29-
_activeRegistryRootPath = string.Format(VbeSettingPathTemplate, vbe.Version);
29+
_activeRegistryRootPath = string.Format(VbeSettingPathTemplate, vbe.Version.Substring(0, 3));
3030
break;
3131
case DllVersion.Vb98:
3232
_activeRegistryRootPath = Vb6SettingPath;

Rubberduck.VBEEditor/VbeRuntime/VbeNativeApiAccessor.cs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,38 +47,21 @@ private static IVbeNativeApi InitializeRuntime()
4747

4848
private static IVbeNativeApi DetermineVersion()
4949
{
50-
IVbeNativeApi runtime;
51-
try
52-
{
53-
runtime = new VbeNativeApi7();
54-
runtime.GetTimer();
55-
_version = DllVersion.Vbe7;
56-
}
57-
catch
50+
foreach (var type in new[] {typeof(VbeNativeApi7), typeof(VbeNativeApi6), typeof(Vb6NativeApi)})
5851
{
5952
try
6053
{
61-
runtime = new VbeNativeApi6();
54+
var runtime = (IVbeNativeApi)Activator.CreateInstance(type);
6255
runtime.GetTimer();
63-
_version = DllVersion.Vbe6;
56+
return runtime;
6457
}
6558
catch
6659
{
67-
try
68-
{
69-
runtime = new Vb6NativeApi();
70-
runtime.GetTimer();
71-
_version = DllVersion.Vb98;
72-
}
73-
catch
74-
{
75-
// we shouldn't be here.... Rubberduck is a VBA add-in, so how the heck could it have loaded without a VBE dll?!?
76-
throw new InvalidOperationException("Cannot execute DoEvents; the VBE dll could not be located.");
77-
}
60+
// ignored
7861
}
7962
}
80-
81-
return _version != DllVersion.Unknown ? runtime : null;
63+
// we shouldn't be here.... Rubberduck is a VBA add-in, so how the heck could it have loaded without a VBE dll?!?
64+
throw new InvalidOperationException("Cannot execute DoEvents; the VBE dll could not be located.");
8265
}
8366

8467
public string DllName => _runtime.DllName;

0 commit comments

Comments
 (0)