Skip to content
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

Merged
merged 34 commits into from Dec 14, 2017

Conversation

IvenBach
Copy link
Member

The first of many.

Update for Rubberduck.UI folder.

@@ -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;
Copy link
Member

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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member Author

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; } }
Copy link
Member

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)
Copy link
Member

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.
Copy link
Member

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;
Copy link
Member

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....

Copy link
Member

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;
Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member

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");
Copy link
Member

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...

Copy link
Member Author

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;
Copy link
Member

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

@bclothier
Copy link
Contributor

Seems to me 17 files were ExtractMethod variety which is being worked upon which will create unnecessary conflicts. I'd request to stash those files from the PR.

@IvenBach
Copy link
Member Author

Is there anything else I ought to revert?

@@ -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)
Copy link
Contributor

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.

@retailcoder retailcoder merged commit 8657b1c into rubberduck-vba:next Dec 14, 2017
@IvenBach IvenBach deleted the Rubberduck.UI_C#6&7_Update branch December 14, 2017 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants