Skip to content

Commit e40380f

Browse files
committed
Code style fixes inside SafeComWrappers namespace
1 parent 99c1235 commit e40380f

Some content is hidden

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

52 files changed

+334
-1002
lines changed

Rubberduck.VBEEditor/SafeComWrappers/Abstract/IVBProjects.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Runtime.InteropServices.ComTypes;
3-
using Rubberduck.VBEditor.Events;
42

53
namespace Rubberduck.VBEditor.SafeComWrappers.Abstract
64
{

Rubberduck.VBEEditor/SafeComWrappers/Abstract/IWindows.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ namespace Rubberduck.VBEditor.SafeComWrappers.Abstract
44
{
55
public struct ToolWindowInfo
66
{
7-
private readonly IWindow _window;
8-
private readonly object _control;
9-
107
public ToolWindowInfo(IWindow window, object control) : this()
118
{
12-
_window = window;
13-
_control = control;
9+
ToolWindow = window;
10+
UserControl = control;
1411
}
1512

16-
public IWindow ToolWindow { get { return _window; } }
17-
public object UserControl { get { return _control; } }
13+
public IWindow ToolWindow { get; }
14+
15+
public object UserControl { get; }
1816
}
1917

2018
public interface IWindows : ISafeComWrapper, IComCollection<IWindow>, IEquatable<IWindows>

Rubberduck.VBEEditor/SafeComWrappers/ComWrapperEnumerator.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ public class ComWrapperEnumerator<TWrapperItem> : IEnumerator<TWrapperItem>
1414
public ComWrapperEnumerator(IEnumerable source, Func<object, TWrapperItem> itemWrapper)
1515
{
1616
_itemWrapper = itemWrapper;
17-
_internal = source == null
18-
? Enumerable.Empty<TWrapperItem>().GetEnumerator()
19-
: source.GetEnumerator();
17+
_internal = source?.GetEnumerator() ?? Enumerable.Empty<TWrapperItem>().GetEnumerator();
2018
}
2119

2220
public void Dispose()
@@ -34,17 +32,8 @@ public void Reset()
3432
_internal.Reset();
3533
}
3634

37-
public TWrapperItem Current
38-
{
39-
get
40-
{
41-
return _itemWrapper.Invoke(_internal.Current);
42-
}
43-
}
35+
public TWrapperItem Current => _itemWrapper.Invoke(_internal.Current);
4436

45-
object IEnumerator.Current
46-
{
47-
get { return Current; }
48-
}
37+
object IEnumerator.Current => Current;
4938
}
5039
}

Rubberduck.VBEEditor/SafeComWrappers/DispatcherEventArgs.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,23 @@ namespace Rubberduck.VBEditor.SafeComWrappers
55
public class DispatcherEventArgs<T> : EventArgs
66
where T : class
77
{
8-
private readonly T _item;
9-
108
public DispatcherEventArgs(T item)
119
{
12-
_item = item;
10+
Item = item;
1311
}
1412

15-
public T Item { get { return _item; } }
13+
public T Item { get; }
1614
}
1715

1816
public class DispatcherRenamedEventArgs<T> : DispatcherEventArgs<T>
1917
where T : class
2018
{
21-
private readonly string _oldName;
22-
2319
public DispatcherRenamedEventArgs(T item, string oldName)
2420
: base(item)
2521
{
26-
_oldName = oldName;
22+
OldName = oldName;
2723
}
2824

29-
public string OldName { get { return _oldName; } }
25+
public string OldName { get; }
3026
}
3127
}

Rubberduck.VBEEditor/SafeComWrappers/Office.Core/AxHostConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ internal class AxHostConverter : AxHost
99
private AxHostConverter()
1010
: base(string.Empty) { }
1111

12-
static public IPictureDisp ImageToPictureDisp(Image image)
12+
public static IPictureDisp ImageToPictureDisp(Image image)
1313
{
1414
return (IPictureDisp)GetIPictureDispFromPicture(image);
1515
}
1616

17-
static public Image PictureDispToImage(IPictureDisp pictureDisp)
17+
public static Image PictureDispToImage(IPictureDisp pictureDisp)
1818
{
1919
return GetPictureFromIPicture(pictureDisp);
2020
}

Rubberduck.VBEEditor/SafeComWrappers/Office.Core/CommandBar.cs

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,76 +11,61 @@ public CommandBar(Microsoft.Office.Core.CommandBar target)
1111
{
1212
}
1313

14-
public int Id
15-
{
16-
get { return IsWrappingNullReference ? 0 : Target.Id; }
17-
}
14+
public int Id => IsWrappingNullReference ? 0 : Target.Id;
1815

19-
public bool IsBuiltIn
20-
{
21-
get { return !IsWrappingNullReference && Target.BuiltIn; }
22-
}
16+
public bool IsBuiltIn => !IsWrappingNullReference && Target.BuiltIn;
2317

24-
public ICommandBarControls Controls
25-
{
26-
get { return new CommandBarControls(IsWrappingNullReference ? null : Target.Controls); }
27-
}
18+
public ICommandBarControls Controls => new CommandBarControls(IsWrappingNullReference ? null : Target.Controls);
2819

2920
public bool IsEnabled
3021
{
31-
get { return !IsWrappingNullReference && Target.Enabled; }
22+
get => !IsWrappingNullReference && Target.Enabled;
3223
set { if (!IsWrappingNullReference) Target.Enabled = value; }
3324
}
3425

3526
public int Height
3627
{
37-
get { return IsWrappingNullReference ? 0 : Target.Height; }
28+
get => IsWrappingNullReference ? 0 : Target.Height;
3829
set { if (!IsWrappingNullReference) Target.Height = value; }
3930
}
4031

41-
public int Index
42-
{
43-
get { return IsWrappingNullReference ? 0 : Target.Index; }
44-
}
32+
public int Index => IsWrappingNullReference ? 0 : Target.Index;
4533

4634
public int Left
4735
{
48-
get { return IsWrappingNullReference ? 0 : Target.Left; }
36+
get => IsWrappingNullReference ? 0 : Target.Left;
4937
set { if (!IsWrappingNullReference) Target.Left = value; }
5038
}
5139

5240
public string Name
5341
{
54-
get { return IsWrappingNullReference ? string.Empty : Target.Name; }
42+
get => IsWrappingNullReference ? string.Empty : Target.Name;
5543
set { if (!IsWrappingNullReference) Target.Name = value; }
5644
}
5745

5846
public CommandBarPosition Position
5947
{
60-
get { return IsWrappingNullReference ? 0 : (CommandBarPosition)Target.Position; }
48+
get => IsWrappingNullReference ? 0 : (CommandBarPosition)Target.Position;
6149
set { if (!IsWrappingNullReference) Target.Position = (Microsoft.Office.Core.MsoBarPosition)value; }
6250
}
6351

6452
public int Top
6553
{
66-
get { return IsWrappingNullReference ? 0 : Target.Top; }
54+
get => IsWrappingNullReference ? 0 : Target.Top;
6755
set { if (!IsWrappingNullReference) Target.Top = value; }
6856
}
6957

70-
public CommandBarType Type
71-
{
72-
get { return IsWrappingNullReference ? 0 : (CommandBarType)Target.Type; }
73-
}
58+
public CommandBarType Type => IsWrappingNullReference ? 0 : (CommandBarType)Target.Type;
7459

7560
public bool IsVisible
7661
{
77-
get { return !IsWrappingNullReference && Target.Visible; }
62+
get => !IsWrappingNullReference && Target.Visible;
7863
set { if (!IsWrappingNullReference) Target.Visible = value; }
7964
}
8065

8166
public int Width
8267
{
83-
get { return IsWrappingNullReference ? 0 : Target.Width; }
68+
get => IsWrappingNullReference ? 0 : Target.Width;
8469
set { if (!IsWrappingNullReference) Target.Width = value; }
8570
}
8671

Rubberduck.VBEEditor/SafeComWrappers/Office.Core/CommandBarButton.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ public CommandBarButton(Microsoft.Office.Core.CommandBarButton target)
1616
{
1717
}
1818

19-
private Microsoft.Office.Core.CommandBarButton Button
20-
{
21-
get { return (Microsoft.Office.Core.CommandBarButton)Target; }
22-
}
19+
private Microsoft.Office.Core.CommandBarButton Button => (Microsoft.Office.Core.CommandBarButton)Target;
2320

2421
public static ICommandBarButton FromCommandBarControl(ICommandBarControl control)
2522
{
@@ -78,31 +75,31 @@ private void Target_Click(Microsoft.Office.Core.CommandBarButton ctrl, ref bool
7875

7976
public bool IsBuiltInFace
8077
{
81-
get { return !IsWrappingNullReference && Button.BuiltInFace; }
78+
get => !IsWrappingNullReference && Button.BuiltInFace;
8279
set { if (!IsWrappingNullReference) Button.BuiltInFace = value; }
8380
}
8481

8582
public int FaceId
8683
{
87-
get { return IsWrappingNullReference ? 0 : Button.FaceId; }
84+
get => IsWrappingNullReference ? 0 : Button.FaceId;
8885
set { if (!IsWrappingNullReference) Button.FaceId = value; }
8986
}
9087

9188
public string ShortcutText
9289
{
93-
get { return IsWrappingNullReference ? string.Empty : Button.ShortcutText; }
90+
get => IsWrappingNullReference ? string.Empty : Button.ShortcutText;
9491
set { if (!IsWrappingNullReference) Button.ShortcutText = value; }
9592
}
9693

9794
public ButtonState State
9895
{
99-
get { return IsWrappingNullReference ? 0 : (ButtonState)Button.State; }
96+
get => IsWrappingNullReference ? 0 : (ButtonState)Button.State;
10097
set { if (!IsWrappingNullReference) Button.State = (Microsoft.Office.Core.MsoButtonState)value; }
10198
}
10299

103100
public ButtonStyle Style
104101
{
105-
get { return IsWrappingNullReference ? 0 : (ButtonStyle)Button.Style; }
102+
get => IsWrappingNullReference ? 0 : (ButtonStyle)Button.Style;
106103
set { if (!IsWrappingNullReference) Button.Style = (Microsoft.Office.Core.MsoButtonStyle)value; }
107104
}
108105

@@ -121,7 +118,7 @@ public void ApplyIcon()
121118

122119
if (!HasPictureProperty)
123120
{
124-
using (var image = CreateTransparentImage(Picture, Mask))
121+
using (var image = CreateTransparentImage(Picture))
125122
{
126123
Clipboard.SetImage(image);
127124
Button.PasteFace();
@@ -169,7 +166,7 @@ private bool HasPictureProperty
169166
}
170167
}
171168

172-
private static Image CreateTransparentImage(Image image, Image mask)
169+
private static Image CreateTransparentImage(Image image)
173170
{
174171
//HACK - just blend image with a SystemColors value (mask is ignored)
175172
//TODO - a real solution would use clipboard formats "Toolbar Button Face" AND "Toolbar Button Mask"

Rubberduck.VBEEditor/SafeComWrappers/Office.Core/CommandBarButtonClickEventArgs.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ namespace Rubberduck.VBEditor.SafeComWrappers.Office.Core
55
{
66
public class CommandBarButtonClickEventArgs : EventArgs
77
{
8-
private readonly ICommandBarButton _control;
9-
108
internal CommandBarButtonClickEventArgs(ICommandBarButton control)
119
{
12-
_control = control;
10+
Control = control;
1311
}
1412

15-
public ICommandBarButton Control { get { return _control; } }
13+
public ICommandBarButton Control { get; }
14+
1615
public bool Cancel { get; set; }
1716
}
1817
}

0 commit comments

Comments
 (0)