Skip to content

Commit

Permalink
Fix version formatting, review comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
comintern committed Nov 14, 2018
1 parent 76cfd9a commit adae41a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Rubberduck.VBEEditor/VBERuntime/Settings/VBESettings.cs
Expand Up @@ -26,7 +26,7 @@ public VbeSettings(IVBE vbe, IRegistryWrapper registry)
{
case DllVersion.Vbe7:
case DllVersion.Vbe6:
_activeRegistryRootPath = string.Format(VbeSettingPathTemplate, vbe.Version);
_activeRegistryRootPath = string.Format(VbeSettingPathTemplate, vbe.Version.Substring(0, 3));
break;
case DllVersion.Vb98:
_activeRegistryRootPath = Vb6SettingPath;
Expand Down
29 changes: 6 additions & 23 deletions Rubberduck.VBEEditor/VbeRuntime/VbeNativeApiAccessor.cs
Expand Up @@ -47,38 +47,21 @@ private static IVbeNativeApi InitializeRuntime()

private static IVbeNativeApi DetermineVersion()
{
IVbeNativeApi runtime;
try
{
runtime = new VbeNativeApi7();
runtime.GetTimer();
_version = DllVersion.Vbe7;
}
catch
foreach (var type in new[] {typeof(VbeNativeApi7), typeof(VbeNativeApi6), typeof(Vb6NativeApi)})
{
try
{
runtime = new VbeNativeApi6();
var runtime = (IVbeNativeApi)Activator.CreateInstance(type);
runtime.GetTimer();
_version = DllVersion.Vbe6;
return runtime;
}
catch
{
try
{
runtime = new Vb6NativeApi();
runtime.GetTimer();
_version = DllVersion.Vb98;
}
catch
{
// we shouldn't be here.... Rubberduck is a VBA add-in, so how the heck could it have loaded without a VBE dll?!?
throw new InvalidOperationException("Cannot execute DoEvents; the VBE dll could not be located.");
}
// ignored
}
}

return _version != DllVersion.Unknown ? runtime : null;
// we shouldn't be here.... Rubberduck is a VBA add-in, so how the heck could it have loaded without a VBE dll?!?
throw new InvalidOperationException("Cannot execute DoEvents; the VBE dll could not be located.");
}

public string DllName => _runtime.DllName;
Expand Down

0 comments on commit adae41a

Please sign in to comment.