Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3586a84
Massive refactor of COM reflection. Much tech debt paid.
comintern Dec 25, 2016
ca722a7
Apparently we *do* care about TKIND_ALIAS, and everything is procedur…
comintern Dec 25, 2016
db38004
Forgot about the parameter count thing, paramarrays.
comintern Dec 25, 2016
10ae5c9
Apparently we DO care about COM structures. Add missed ctor initializ…
comintern Dec 25, 2016
4eb9a25
Fix bad COM enum asTypeNames (woops). Removed asserts.
comintern Dec 25, 2016
0336253
Fixed structure scope, parameter scope, simplify name creation in cto…
comintern Dec 25, 2016
58d595f
Fix constant types, finished the struct members I forgot, consolidate…
comintern Dec 26, 2016
c433ff7
Merge branch 'next' of https://github.com/comintern/Rubberduck.git
comintern Dec 26, 2016
445e747
Merge branch 'next' into next
comintern Dec 26, 2016
a4911b7
De-consolidate enums and types again (:sigh:), hook serialization bac…
comintern Dec 26, 2016
e74a1ff
Ooops, fixed NRE in deserialization.
comintern Dec 26, 2016
eee2ecb
Merge branch 'next' of https://github.com/comintern/Rubberduck.git
comintern Dec 26, 2016
841ab81
Use window visibililty settings on startup.
comintern Dec 26, 2016
3c36eda
True = true now for visibility. (oops.)
comintern Dec 26, 2016
45552df
Add RD version to logging, log startup environment. Closes #2461
comintern Dec 26, 2016
f891c71
Add reflection based host discovery (should be much more robust than …
comintern Dec 27, 2016
bcfbfb1
Add utility class for event hooks, stubbed code in VBE.
comintern Dec 27, 2016
1de88d4
Merge pull request #2462 from comintern/next
retailcoder Dec 27, 2016
4f43877
Disable CommandBars.Release() again to synch.
comintern Dec 27, 2016
129b98f
Merge branch 'next' into next
comintern Dec 27, 2016
69c3587
Merge pull request #2463 from comintern/next
retailcoder Dec 28, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion RetailCoder.VBE/App.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System.IO;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Infralution.Localization.Wpf;
using NLog;
using NLog.Fluent;
using Rubberduck.Common;
using Rubberduck.Parsing;
using Rubberduck.Parsing.Symbols;
Expand Down Expand Up @@ -145,6 +148,7 @@ private void UpdateLoggingLevel()
public void Startup()
{
EnsureLogFolderPathExists();
LogRubberduckSart();
LoadConfig();
CheckForLegacyIndenterSettings();
_appMenus.Initialize();
Expand Down Expand Up @@ -223,6 +227,21 @@ private void CheckForLegacyIndenterSettings()
}
}

private void LogRubberduckSart()
{
var version = GetType().Assembly.GetName().Version.ToString();
GlobalDiagnosticsContext.Set("RubberduckVersion", version);
var headers = new List<string>
{
string.Format("Rubberduck version {0} loading:", version),
string.Format("\tOperating System: {0} {1}", Environment.OSVersion.VersionString, Environment.Is64BitOperatingSystem ? "x64" : "x86"),
string.Format("\tHost Product: {0} {1}", Application.ProductName, Environment.Is64BitProcess ? "x64" : "x86"),
string.Format("\tHost Version: {0}", Application.ProductVersion),
string.Format("\tHost Executable: {0}", Path.GetFileName(Application.ExecutablePath)),
};
Logger.Log(LogLevel.Info, string.Join(Environment.NewLine, headers));
}

private bool _disposed;
public void Dispose()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
&& !declaration.IsSelfAssigned
&& !declaration.References.Any(reference => reference.IsAssignment));

var lenFunction = BuiltInDeclarations.SingleOrDefault(s => s.Scope == "VBE7.DLL;VBA.Strings.Len");
var lenbFunction = BuiltInDeclarations.SingleOrDefault(s => s.Scope == "VBE7.DLL;VBA.Strings.LenB");
//The parameter scoping was apparently incorrect before - need to filter for the actual function.
var lenFunction = BuiltInDeclarations.SingleOrDefault(s => s.DeclarationType == DeclarationType.Function && s.Scope.Equals("VBE7.DLL;VBA.Strings.Len"));
var lenbFunction = BuiltInDeclarations.SingleOrDefault(s => s.DeclarationType == DeclarationType.Function && s.Scope.Equals("VBE7.DLL;VBA.Strings.Len"));

return from issue in declarations
where issue.References.Any()
Expand Down
2 changes: 1 addition & 1 deletion RetailCoder.VBE/NLog.dll.nlog
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xsi:type="File"
name="file"
fileName="${specialfolder:folder=ApplicationData}/Rubberduck/Logs/RubberduckLog.txt"
layout="${longdate};${uppercase:${level}};${logger};${message};${exception:format=tostring}"
layout="${longdate};${uppercase:${level}}-${gdc:item=RubberduckVersion};${logger};${message};${exception:format=tostring}"
archiveFileName="${specialfolder:folder=ApplicationData}/Rubberduck/Logs/archives/RubberduckLog.{#}.txt"
archiveAboveSize="5242880"
archiveNumbering="Sequence"
Expand Down
37 changes: 37 additions & 0 deletions RetailCoder.VBE/Settings/WindowSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
using System.Xml.Serialization;
using Rubberduck.Properties;
using Rubberduck.UI;
using Rubberduck.UI.CodeExplorer;
using Rubberduck.UI.Inspections;
using Rubberduck.UI.SourceControl;
using Rubberduck.UI.ToDoItems;
using Rubberduck.UI.UnitTesting;

namespace Rubberduck.Settings
{
Expand All @@ -9,6 +16,8 @@ public interface IWindowSettings
bool SourceControlVisibleOnStartup { get; set; }
bool TestExplorerVisibleOnStartup { get; set; }
bool TodoExplorerVisibleOnStartup { get; set; }

bool IsWindowVisible(DockableToolwindowPresenter candidate);
}

[XmlType(AnonymousType = true)]
Expand All @@ -34,5 +43,33 @@ public WindowSettings(bool codeExplorerVisibleOnStartup, bool codeInspectionsVis
public bool SourceControlVisibleOnStartup { get; set; }
public bool TestExplorerVisibleOnStartup { get; set; }
public bool TodoExplorerVisibleOnStartup { get; set; }

public bool IsWindowVisible(DockableToolwindowPresenter candidate)
{
//I'm sure there's a better way to do this, because this is a lazy-ass way to do it.
//We're injecting into the base class, so check the derived class:
if (candidate is CodeExplorerDockablePresenter)
{
return CodeExplorerVisibleOnStartup;
}
if (candidate is CodeInspectionsDockablePresenter)
{
return CodeInspectionsVisibleOnStartup;
}
if (candidate is SourceControlDockablePresenter)
{
return SourceControlVisibleOnStartup;
}
if (candidate is TestExplorerDockablePresenter)
{
return TestExplorerVisibleOnStartup;
}
if (candidate is ToDoExplorerDockablePresenter)
{
return TodoExplorerVisibleOnStartup;
}
//Oh. Hello. I have no clue who you are...
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
using Rubberduck.Settings;
using Rubberduck.SettingsProvider;
using Rubberduck.VBEditor.SafeComWrappers.Abstract;

namespace Rubberduck.UI.CodeExplorer
{
public class CodeExplorerDockablePresenter : DockableToolwindowPresenter
{
public CodeExplorerDockablePresenter(IVBE vbe, IAddIn addIn, CodeExplorerWindow view)
: base(vbe, addIn, view)
public CodeExplorerDockablePresenter(IVBE vbe, IAddIn addIn, CodeExplorerWindow view, IConfigProvider<WindowSettings> settings)
: base(vbe, addIn, view, settings)
{
}
}
Expand Down
4 changes: 2 additions & 2 deletions RetailCoder.VBE/UI/Controls/SearchResultsDockablePresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace Rubberduck.UI.Controls
{
public class SearchResultsDockablePresenter : DockableToolwindowPresenter
{
public SearchResultsDockablePresenter(IVBE vbe, IAddIn addin, IDockableUserControl view)
: base(vbe, addin, view)
public SearchResultsDockablePresenter(IVBE vbe, IAddIn addin, IDockableUserControl view)
: base(vbe, addin, view, null)
{
}

Expand Down
12 changes: 10 additions & 2 deletions RetailCoder.VBE/UI/DockableToolwindowPresenter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.Configuration;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using NLog;
using Rubberduck.Settings;
using Rubberduck.SettingsProvider;
using Rubberduck.VBEditor.SafeComWrappers.Abstract;

namespace Rubberduck.UI
Expand All @@ -23,13 +26,18 @@ public abstract class DockableToolwindowPresenter : IDockablePresenter, IDisposa
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IWindow _window;
private readonly UserControl _userControl;
private readonly WindowSettings _settings; //Storing this really doesn't matter - it's only checked on startup and never persisted.

protected DockableToolwindowPresenter(IVBE vbe, IAddIn addin, IDockableUserControl view)
protected DockableToolwindowPresenter(IVBE vbe, IAddIn addin, IDockableUserControl view, IConfigProvider<WindowSettings> settingsProvider)
{
_vbe = vbe;
_addin = addin;
Logger.Trace(string.Format("Initializing Dockable Panel ({0})", GetType().Name));
_userControl = view as UserControl;
if (settingsProvider != null)
{
_settings = settingsProvider.Create();
}
_window = CreateToolWindow(view);
}

Expand Down Expand Up @@ -69,7 +77,7 @@ private IWindow CreateToolWindow(IDockableUserControl control)

EnsureMinimumWindowSize(toolWindow);

toolWindow.IsVisible = false; //hide it again
toolWindow.IsVisible = _settings != null && _settings.IsWindowVisible(this);

userControlHost.AddUserControl(control as UserControl, new IntPtr(_vbe.MainWindow.HWnd));
return toolWindow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Rubberduck.UI.IdentifierReferences
public class IdentifierReferencesListDockablePresenter : DockableToolwindowPresenter
{
public IdentifierReferencesListDockablePresenter(IVBE vbe, IAddIn addin, SimpleListControl control, Declaration target)
: base(vbe, addin, control)
: base(vbe, addin, control, null)
{
BindTarget(target);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Rubberduck.UI.IdentifierReferences
public class ImplementationsListDockablePresenter : DockableToolwindowPresenter
{
public ImplementationsListDockablePresenter(IVBE vbe, IAddIn addin, IDockableUserControl control, IEnumerable<Declaration> implementations)
: base(vbe, addin, control)
: base(vbe, addin, control, null)
{
BindTarget(implementations);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
using Rubberduck.Settings;
using Rubberduck.SettingsProvider;
using Rubberduck.VBEditor.SafeComWrappers.Abstract;

namespace Rubberduck.UI.Inspections
{
public class CodeInspectionsDockablePresenter : DockableToolwindowPresenter
{
public CodeInspectionsDockablePresenter(IVBE vbe, IAddIn addin, CodeInspectionsWindow window)
:base(vbe, addin, window)
public CodeInspectionsDockablePresenter(IVBE vbe, IAddIn addin, CodeInspectionsWindow window, IConfigProvider<WindowSettings> settings)
: base(vbe, addin, window, settings)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion RetailCoder.VBE/UI/ParserErrors/ParserErrorsPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IParserErrorsPresenter
public class ParserErrorsPresenter : DockableToolwindowPresenter, IParserErrorsPresenter
{
public ParserErrorsPresenter(IVBE vbe, IAddIn addin)
: base(vbe, addin, new SimpleListControl(RubberduckUI.ParseErrors_Caption))
: base(vbe, addin, new SimpleListControl(RubberduckUI.ParseErrors_Caption), null)
{
_source = new BindingList<ParseErrorListItem>();
var control = UserControl as SimpleListControl;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Diagnostics;
using Rubberduck.Settings;
using Rubberduck.SettingsProvider;
using Rubberduck.VBEditor.SafeComWrappers.Abstract;

namespace Rubberduck.UI.SourceControl
Expand All @@ -8,8 +10,8 @@ namespace Rubberduck.UI.SourceControl
/// </summary>
public class SourceControlDockablePresenter : DockableToolwindowPresenter
{
public SourceControlDockablePresenter(IVBE vbe, IAddIn addin, SourceControlPanel window)
: base(vbe, addin, window)
public SourceControlDockablePresenter(IVBE vbe, IAddIn addin, SourceControlPanel window, IConfigProvider<WindowSettings> settings)
: base(vbe, addin, window, settings)
{
}

Expand Down
8 changes: 5 additions & 3 deletions RetailCoder.VBE/UI/ToDoItems/ToDoExplorerDockablePresenter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
using Rubberduck.Settings;
using Rubberduck.SettingsProvider;
using Rubberduck.VBEditor.SafeComWrappers.Abstract;

namespace Rubberduck.UI.ToDoItems
{
Expand All @@ -7,8 +9,8 @@ namespace Rubberduck.UI.ToDoItems
/// </summary>
public class ToDoExplorerDockablePresenter : DockableToolwindowPresenter
{
public ToDoExplorerDockablePresenter(IVBE vbe, IAddIn addin, ToDoExplorerWindow window)
: base(vbe, addin, window)
public ToDoExplorerDockablePresenter(IVBE vbe, IAddIn addin, ToDoExplorerWindow window, IConfigProvider<WindowSettings> settings)
: base(vbe, addin, window, settings)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
using Rubberduck.Settings;
using Rubberduck.SettingsProvider;
using Rubberduck.VBEditor.SafeComWrappers.Abstract;

namespace Rubberduck.UI.UnitTesting
{
public class TestExplorerDockablePresenter : DockableToolwindowPresenter
{
public TestExplorerDockablePresenter(IVBE vbe, IAddIn addin, TestExplorerWindow view)
: base(vbe, addin, view)
public TestExplorerDockablePresenter(IVBE vbe, IAddIn addin, TestExplorerWindow view, IConfigProvider<WindowSettings> settings)
: base(vbe, addin, view, settings)
{
}
}
Expand Down
52 changes: 52 additions & 0 deletions Rubberduck.Parsing/ComReflection/ComBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices.ComTypes;
using Rubberduck.Parsing.Symbols;
using FUNCDESC = System.Runtime.InteropServices.ComTypes.FUNCDESC;

namespace Rubberduck.Parsing.ComReflection
{
public interface IComBase
{
Guid Guid { get; }
int Index { get; }
ComDocumentation Documentation { get; }
string Name { get; }
DeclarationType Type { get; }
}

public abstract class ComBase : IComBase
{
public Guid Guid { get; protected set; }
public int Index { get; protected set; }
public ComDocumentation Documentation { get; protected set; }
public string Name
{
get { return Documentation == null ? string.Empty : Documentation.Name; }
}

public DeclarationType Type { get; protected set; }

protected ComBase(ITypeLib typeLib, int index)
{
Index = index;
Documentation = new ComDocumentation(typeLib, index);
}

protected ComBase(ITypeInfo info)
{
ITypeLib typeLib;
int index;
info.GetContainingTypeLib(out typeLib, out index);
Index = index;
Debug.Assert(typeLib != null);
Documentation = new ComDocumentation(typeLib, index);
}

protected ComBase(ITypeInfo info, FUNCDESC funcDesc)
{
Index = funcDesc.memid;
Documentation = new ComDocumentation(info, funcDesc.memid);
}
}
}
Loading