Skip to content

Commit 993301b

Browse files
committed
Merge remote-tracking branch 'upstream/next' into rkapka-master
# Conflicts: # RetailCoder.VBE/UI/Command/CodeExplorerCommand.cs # RetailCoder.VBE/UI/Command/ExportAllCommand.cs # RetailCoder.VBE/UI/Command/FindSymbolCommand.cs # RetailCoder.VBE/UI/Command/InspectionResultsCommand.cs # RetailCoder.VBE/UI/Command/Refactorings/CodePaneRefactorRenameCommand.cs # RetailCoder.VBE/UI/Command/Refactorings/RefactorExtractMethodCommand.cs # RetailCoder.VBE/UI/Command/Refactorings/RefactorMoveCloserToUsageCommand.cs # RetailCoder.VBE/UI/Command/ReparseCommand.cs # RetailCoder.VBE/UI/Command/SourceControlCommand.cs # RetailCoder.VBE/UI/Command/TestExplorerCommand.cs
2 parents b9fb596 + ca33f0b commit 993301b

File tree

236 files changed

+1533
-2036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

236 files changed

+1533
-2036
lines changed

RetailCoder.VBE/Extension.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,17 @@ public void OnConnection(object Application, ext_ConnectMode ConnectMode, object
5252
{
5353
try
5454
{
55-
if (Application is Microsoft.Vbe.Interop.VBE)
55+
if (Application is Microsoft.Vbe.Interop.VBE vbe1)
5656
{
57-
var vbe = (VBE) Application;
58-
_ide = new VBEditor.SafeComWrappers.VBA.VBE(vbe);
57+
_ide = new VBEditor.SafeComWrappers.VBA.VBE(vbe1);
5958
VBENativeServices.HookEvents(_ide);
6059

6160
var addin = (AddIn)AddInInst;
6261
_addin = new VBEditor.SafeComWrappers.VBA.AddIn(addin) { Object = this };
6362
}
64-
else if (Application is Microsoft.VB6.Interop.VBIDE.VBE)
63+
else if (Application is Microsoft.VB6.Interop.VBIDE.VBE vbe2)
6564
{
66-
var vbe = Application as Microsoft.VB6.Interop.VBIDE.VBE;
67-
_ide = new VBEditor.SafeComWrappers.VB6.VBE(vbe);
65+
_ide = new VBEditor.SafeComWrappers.VB6.VBE(vbe2);
6866

6967
var addin = (Microsoft.VB6.Interop.VBIDE.AddIn) AddInInst;
7068
_addin = new VBEditor.SafeComWrappers.VB6.AddIn(addin);
@@ -87,7 +85,7 @@ public void OnConnection(object Application, ext_ConnectMode ConnectMode, object
8785
}
8886
}
8987

90-
Assembly LoadFromSameFolder(object sender, ResolveEventArgs args)
88+
private Assembly LoadFromSameFolder(object sender, ResolveEventArgs args)
9189
{
9290
var folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty;
9391
var assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
@@ -193,8 +191,13 @@ private void InitializeAddIn()
193191
catch (Exception exception)
194192
{
195193
_logger.Fatal(exception);
196-
System.Windows.Forms.MessageBox.Show(exception.ToString(), RubberduckUI.RubberduckLoadFailure,
197-
MessageBoxButtons.OK, MessageBoxIcon.Error);
194+
System.Windows.Forms.MessageBox.Show(
195+
#if DEBUG
196+
exception.ToString(),
197+
#else
198+
exception.Message.ToString(),
199+
#endif
200+
RubberduckUI.RubberduckLoadFailure, MessageBoxButtons.OK, MessageBoxIcon.Error);
198201
}
199202
finally
200203
{
@@ -216,13 +219,14 @@ private void Startup()
216219
_app.Startup();
217220

218221
_isInitialized = true;
219-
220222
}
221223
catch (Exception e)
222224
{
223225
_logger.Log(LogLevel.Fatal, e, "Startup sequence threw an unexpected exception.");
224226
#if DEBUG
225-
throw; // <<~ uncomment to crash the process
227+
throw;
228+
#else
229+
throw new Exception("Rubberduck's startup sequence threw an unexpected exception. Please check the Rubberduck logs for more information and report an issue if necessary");
226230
#endif
227231
}
228232
}

RetailCoder.VBE/UI/About/AboutControl.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private void CopyVersionInfo_MouseLeftButtonDown(object sender, MouseButtonEvent
3333
private void CopyVersionInfoToClipboard()
3434
{
3535
var sb = new System.Text.StringBuilder();
36-
sb.AppendLine($"Rubberduck version: {this.Version.Text}");
36+
sb.AppendLine($"Rubberduck version: {Version.Text}");
3737
sb.AppendLine($"Operating System: {Environment.OSVersion.VersionString}, {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}");
3838
sb.AppendLine($"Host Product: {Application.ProductName} {(Environment.Is64BitProcess ? "x64" : "x86")}");
3939
sb.AppendLine($"Host Version: {Application.ProductVersion}");

RetailCoder.VBE/UI/CodeExplorer/Commands/RemoveCommand.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ protected override bool EvaluateCanExecute(object parameter)
4040

4141
var node = (CodeExplorerComponentViewModel)parameter;
4242
var componentType = node.Declaration.QualifiedName.QualifiedModuleName.ComponentType;
43+
44+
if (componentType == ComponentType.Document)
45+
{
46+
return false;
47+
}
48+
4349
return _exportableFileExtensions.Select(s => s.Key).Contains(componentType);
4450
}
4551

@@ -72,8 +78,7 @@ private bool ExportFile(CodeExplorerComponentViewModel node)
7278
{
7379
var component = node.Declaration.QualifiedName.QualifiedModuleName.Component;
7480

75-
string ext;
76-
_exportableFileExtensions.TryGetValue(component.Type, out ext);
81+
_exportableFileExtensions.TryGetValue(component.Type, out string ext);
7782

7883
_saveFileDialog.FileName = component.Name + ext;
7984
var result = _saveFileDialog.ShowDialog();

RetailCoder.VBE/UI/Command/AddTestModuleCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public AddTestModuleCommand(IVBE vbe, RubberduckParserState state, IGeneralConfi
3232
_configLoader = configLoader;
3333
}
3434

35-
private string TestModuleEmptyTemplate = new StringBuilder()
35+
private readonly string _testModuleEmptyTemplate = new StringBuilder()
3636
.AppendLine("'@TestModule")
3737
.AppendLine("'@Folder(\"Tests\")")
3838
.AppendLine()
@@ -81,10 +81,10 @@ private string GetTestModule(IUnitTestSettings settings)
8181
var assertType = string.Format("Rubberduck.{0}AssertClass", settings.AssertMode == AssertMode.StrictAssert ? string.Empty : "Permissive");
8282
var assertDeclaredAs = DeclarationFormatFor(AssertFieldDeclarationFormat, assertType, settings);
8383

84-
var fakesType = "Rubberduck.FakesProvider";
84+
const string fakesType = "Rubberduck.FakesProvider";
8585
var fakesDeclaredAs = DeclarationFormatFor(FakesFieldDeclarationFormat, fakesType, settings);
8686

87-
var formattedModuleTemplate = string.Format(TestModuleEmptyTemplate, assertDeclaredAs, fakesDeclaredAs);
87+
var formattedModuleTemplate = string.Format(_testModuleEmptyTemplate, assertDeclaredAs, fakesDeclaredAs);
8888

8989
if (settings.ModuleInit)
9090
{

RetailCoder.VBE/UI/Command/ExportAllCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Rubberduck.UI.Command
1111
public class ExportAllCommand : CommandBase
1212
{
1313
private readonly IVBE _vbe;
14-
private IFolderBrowserFactory _factory;
14+
private readonly IFolderBrowserFactory _factory;
1515

1616
public ExportAllCommand(IVBE vbe, IFolderBrowserFactory folderBrowserFactory) : base(LogManager.GetCurrentClassLogger())
1717
{
@@ -45,7 +45,7 @@ protected override void OnExecute(object parameter)
4545

4646
var vbproject = parameter as IVBProject;
4747

48-
IVBProject project = projectNode?.Declaration.Project ?? vbproject ?? _vbe.ActiveVBProject;
48+
var project = projectNode?.Declaration.Project ?? vbproject ?? _vbe.ActiveVBProject;
4949

5050
var desc = string.Format(RubberduckUI.ExportAllCommand_SaveAsDialog_Title, project.Name);
5151

RetailCoder.VBE/UI/Command/FindAllImplementationsCommand.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class FindAllImplementationsCommand : CommandBase, IDisposable
2727
private readonly SearchResultPresenterInstanceManager _presenterService;
2828
private readonly IVBE _vbe;
2929

30-
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
30+
private new static readonly Logger Logger = LogManager.GetCurrentClassLogger();
3131

3232
public FindAllImplementationsCommand(INavigateCommand navigateCommand, IMessageBox messageBox,
3333
RubberduckParserState state, IVBE vbe, ISearchResultsWindowViewModel viewModel,
@@ -166,8 +166,7 @@ private SearchResultsViewModel CreateViewModel(Declaration target)
166166

167167
private Declaration FindTarget(object parameter)
168168
{
169-
var declaration = parameter as Declaration;
170-
if (declaration != null)
169+
if (parameter is Declaration declaration)
171170
{
172171
return declaration;
173172
}
@@ -178,10 +177,9 @@ private Declaration FindTarget(object parameter)
178177
private IEnumerable<Declaration> FindImplementations(Declaration target)
179178
{
180179
var items = _state.AllDeclarations;
181-
string name;
182180
var implementations = (target.DeclarationType == DeclarationType.ClassModule
183-
? FindAllImplementationsOfClass(target, items, out name)
184-
: FindAllImplementationsOfMember(target, items, out name)) ?? new List<Declaration>();
181+
? FindAllImplementationsOfClass(target, items, out _)
182+
: FindAllImplementationsOfMember(target, items, out _)) ?? new List<Declaration>();
185183

186184
return implementations;
187185
}

RetailCoder.VBE/UI/Command/MenuItems/CommandBars/IContextFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public string Format(ICodePane activeCodePane, Declaration declaration)
3535
var codePaneSelectionText = selection.Selection.ToString();
3636
var contextSelectionText = FormatDeclaration(declaration);
3737

38-
return string.Format("{0} | {1}", codePaneSelectionText, contextSelectionText);
38+
return $"{codePaneSelectionText} | {contextSelectionText}";
3939
}
4040

4141
public string Format(Declaration declaration, bool multipleControls)

RetailCoder.VBE/UI/Command/MenuItems/CommandBars/SerializeDeclarationsCommandMenuItem.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ protected override void OnExecute(object parameter)
4747
{
4848
System.Diagnostics.Debug.Assert(path != null, "project path isn't supposed to be null");
4949

50-
var filename = string.Format("{0}.{1}.{2}", tree.Node.QualifiedMemberName.QualifiedModuleName.ProjectName, tree.MajorVersion, tree.MinorVersion) + ".xml";
50+
var filename = string.Format("{0}.{1}.{2}.xml",
51+
tree.Node.QualifiedMemberName.QualifiedModuleName.ProjectName,
52+
tree.MajorVersion,
53+
tree.MinorVersion);
5154
_service.Persist(Path.Combine(path, filename), tree);
5255
}
5356
}

RetailCoder.VBE/UI/Command/MenuItems/CommandMenuItemBase.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ public abstract class CommandMenuItemBase : ICommandMenuItem
1010
{
1111
protected CommandMenuItemBase(CommandBase command)
1212
{
13-
_command = command;
13+
Command = command;
1414
}
1515

16-
private readonly CommandBase _command;
17-
public CommandBase Command => _command;
16+
public CommandBase Command { get; }
1817

1918
public abstract string Key { get; }
2019

@@ -47,7 +46,7 @@ public virtual Func<string> ToolTipText
4746
/// <remarks>Returns <c>true</c> if not overridden.</remarks>
4847
public virtual bool EvaluateCanExecute(RubberduckParserState state)
4948
{
50-
return state != null && (_command?.CanExecute(state) ?? false);
49+
return state != null && (Command?.CanExecute(state) ?? false);
5150
}
5251

5352
public virtual ButtonStyle ButtonStyle => ButtonStyle.IconAndCaption;

RetailCoder.VBE/UI/Command/MenuItems/FormDesignerFindAllReferencesCommandMenuItem.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ public FormDesignerFindAllReferencesCommandMenuItem(CommandBase command)
1010
{
1111
}
1212

13-
public override bool BeginGroup { get { return true; } }
14-
public override string Key { get { return "ContextMenu_FindAllReferences"; } }
15-
public override int DisplayOrder { get { return (int)NavigationMenuItemDisplayOrder.FindAllReferences; } }
13+
public override bool BeginGroup => true;
14+
public override string Key => "ContextMenu_FindAllReferences";
15+
public override int DisplayOrder => (int)NavigationMenuItemDisplayOrder.FindAllReferences;
1616

1717
public override bool EvaluateCanExecute(RubberduckParserState state)
1818
{

0 commit comments

Comments
 (0)