Skip to content

Commit 8657b1c

Browse files
authored
Merge pull request #3562 from IvenBach/Rubberduck.UI_C#6&7_Update
C#6/7 syntax updates
2 parents 6e2fa78 + 2f8bd06 commit 8657b1c

File tree

80 files changed

+551
-904
lines changed

Some content is hidden

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

80 files changed

+551
-904
lines changed

RetailCoder.VBE/Extension.cs

Lines changed: 5 additions & 7 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");

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/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/CodeExplorerCommand.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ public CodeExplorerCommand(IDockablePresenter presenter)
1818
_presenter = presenter;
1919
}
2020

21-
public override RubberduckHotkey Hotkey
22-
{
23-
get { return RubberduckHotkey.CodeExplorer; }
24-
}
21+
public override RubberduckHotkey Hotkey => RubberduckHotkey.CodeExplorer;
2522

2623
protected override void OnExecute(object parameter)
2724
{

RetailCoder.VBE/UI/Command/CommandBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public void Execute(object parameter)
6464

6565
public event EventHandler CanExecuteChanged
6666
{
67-
add { CommandManager.RequerySuggested += value; }
68-
remove { CommandManager.RequerySuggested -= value; }
67+
add => CommandManager.RequerySuggested += value;
68+
remove => CommandManager.RequerySuggested -= value;
6969
}
7070
}
7171
}

RetailCoder.VBE/UI/Command/ExportAllCommand.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ namespace Rubberduck.UI.Command
1212
public class ExportAllCommand : CommandBase
1313
{
1414
private readonly IVBE _vbe;
15-
private IFolderBrowserFactory _factory;
15+
private readonly IFolderBrowserFactory _factory;
1616

1717
public ExportAllCommand(IVBE vbe, IFolderBrowserFactory folderBrowserFactory) : base(LogManager.GetCurrentClassLogger())
1818
{
1919
_vbe = vbe;
2020
_factory = folderBrowserFactory;
2121
}
2222

23-
public override RubberduckHotkey Hotkey
24-
{
25-
get { return RubberduckHotkey.ExportActiveProject; }
26-
}
23+
public override RubberduckHotkey Hotkey => RubberduckHotkey.ExportActiveProject;
2724

2825
protected override bool EvaluateCanExecute(object parameter)
2926
{
@@ -51,7 +48,7 @@ protected override void OnExecute(object parameter)
5148

5249
var vbproject = parameter as IVBProject;
5350

54-
IVBProject project = projectNode?.Declaration.Project ?? vbproject ?? _vbe.ActiveVBProject;
51+
var project = projectNode?.Declaration.Project ?? vbproject ?? _vbe.ActiveVBProject;
5552

5653
var desc = string.Format(RubberduckUI.ExportAllCommand_SaveAsDialog_Title, project.Name);
5754

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/FindSymbolCommand.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ public FindSymbolCommand(IVBE vbe, RubberduckParserState state, DeclarationIconC
2727
_iconCache = iconCache;
2828
}
2929

30-
public override RubberduckHotkey Hotkey
31-
{
32-
get { return RubberduckHotkey.FindSymbol; }
33-
}
30+
public override RubberduckHotkey Hotkey => RubberduckHotkey.FindSymbol;
3431

3532
protected override void OnExecute(object parameter)
3633
{

RetailCoder.VBE/UI/Command/InspectionResultsCommand.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ public InspectionResultsCommand(IDockablePresenter presenter)
1818
_presenter = presenter;
1919
}
2020

21-
public override RubberduckHotkey Hotkey
22-
{
23-
get { return RubberduckHotkey.InspectionResults; }
24-
}
21+
public override RubberduckHotkey Hotkey => RubberduckHotkey.InspectionResults;
2522

2623
/// <summary>
2724
/// Runs code inspections

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)

0 commit comments

Comments
 (0)