New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rubberduck.UI folder C#6&7 update #3562
Rubberduck.UI folder C#6&7 update #3562
Conversation
RetailCoder.VBE/Extension.cs
Outdated
@@ -52,7 +52,7 @@ public void OnConnection(object Application, ext_ConnectMode ConnectMode, object | |||
{ | |||
try | |||
{ | |||
if (Application is Microsoft.Vbe.Interop.VBE) | |||
if (Application is VBE) | |||
{ | |||
var vbe = (VBE) Application; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be simplified to if (Application is VBE vbe)
, which eliminates the cast
@@ -182,6 +179,7 @@ private void child_Click(object sender, CommandBarButtonClickEventArgs e) | |||
return; | |||
} | |||
|
|||
//Logger.Debug("({0}) Executing click handler for menu item '{1}', hash code {2}", GetHashCode(), e.Control.Caption, e.Control.Target.GetHashCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove 😊
@@ -12,8 +12,6 @@ public RefactorEncapsulateFieldCommandMenuItem(CommandBase command) | |||
|
|||
public override string Key => "RefactorMenu_EncapsulateField"; | |||
public override int DisplayOrder => (int)RefactoringsMenuItemDisplayOrder.EncapsulateField; | |||
//public override Image Image { get { return Resources.AddProperty_5538_32; } } | |||
//public override Image Mask { get { return Resources.AddProperty_5538_321_Mask; } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -17,7 +17,7 @@ public class NavigateCommand : CommandBase, INavigateCommand | |||
protected override void OnExecute(object parameter) | |||
{ | |||
var param = parameter as NavigateCodeEventArgs; | |||
if (param == null || param.QualifiedName.Component == null) | |||
if (param?.QualifiedName.Component == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC this is not quite equivalent, because if param is null
then param?.QualifiedName
is null, which can cause a NullReferenceException now. I think I'd keep it the old way here
{ | ||
Func<QualifiedSelection?, string, IExtractMethodModel> createMethodModel = (qs, code) => | ||
var extraction = new ExtractMethodExtraction(); | ||
// bug: access to disposed closure - todo: make ExtractMethodRefactoring request reparse like everyone else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe put the todo in a separate line? And possibly remove it, because it's not a concern for this place, but the refactoring.Refactor()
@@ -36,7 +36,7 @@ public static string Convert(string value) | |||
public static string ConvertBack(string value) | |||
{ | |||
var tuple = _keys.SingleOrDefault(k => k.Item2 == value); | |||
return tuple == null ? value : tuple.Item1.ToString(); | |||
return tuple?.Item1.ToString() ?? value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar concerns as with the previous refactoring involving null-coalescing. Item1 can be null this way....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If tuple?.Item1
is null
, the whole expression stops.
return _isBusy ? Visibility.Hidden : Visibility.Visible; | ||
} | ||
} | ||
public Visibility EmptyUIRefreshMessageVisibility => _isBusy ? Visibility.Hidden : Visibility.Visible; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should access the Property to be consistent with line 510
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So converting both back to the way it was?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no. this would be => IsBusy ? [...]
@@ -24,6 +24,11 @@ public class InspectionSeverityImageSourceConverter : IValueConverter | |||
|
|||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
if (value == null) | |||
{ | |||
throw new ArgumentException("Value parameter must be non-null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why bring the nukes out directly? Log an error and return a default. Don't blow it all to smithereens directly...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible 'System.NullReferenceException
was brought up. Thought this was the proper way of addressing that.
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow .... that's a lot of usings
Seems to me 17 files were |
Is there anything else I ought to revert? |
…nto Rubberduck.UI_C#6&7_Update
…nto Rubberduck.UI_C#6&7_Update
RetailCoder.VBE/Extension.cs
Outdated
@@ -52,19 +52,17 @@ public void OnConnection(object Application, ext_ConnectMode ConnectMode, object | |||
{ | |||
try | |||
{ | |||
if (Application is Microsoft.Vbe.Interop.VBE) | |||
if (Application is VBE vbe1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prefix might be redundant, but it is telling us that we are dealing with a RCW and not with a class we control.
…nto Rubberduck.UI_C#6&7_Update
The first of many.
Update for Rubberduck.UI folder.