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

More nullable checks and fixed minor bugs #378

Closed
wants to merge 1 commit into from

Conversation

GermanAizek
Copy link

@GermanAizek GermanAizek commented May 25, 2022

@Klocman, review pr code changes and feedback me.

Copy link
Owner

@Klocman Klocman left a comment

Choose a reason for hiding this comment

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

Thank you for the PR!

Most of the changes are unnecessary as explained in the comments. Please either undo them or place the DisplayVersion fix and other fixes to confirmed issues in a separate PR.

var valueNames = targetKey.GetValueNames();
var valueNames = targetKey?.GetValueNames();
Copy link
Owner

Choose a reason for hiding this comment

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

With the check added this will throw a nullreference in the next line instead.

@@ -549,7 +549,7 @@ public void UninstallFromDirectory(IEnumerable<ApplicationUninstallerEntry> allU
if (item.UninstallPossible && item.UninstallerKind != UninstallerType.SimpleDelete &&
MessageBoxes.UninstallFromDirectoryUninstallerFound(item.DisplayName, item.UninstallString))
{
item.RunUninstaller(false, Settings.Default.AdvancedSimulate).WaitForExit(60000);
item?.RunUninstaller(false, Settings.Default.AdvancedSimulate).WaitForExit(60000);
Copy link
Owner

Choose a reason for hiding this comment

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

With the check added this will throw a nullreference in the next line instead.

@@ -30,7 +30,7 @@ public override void Render(Graphics g, Rectangle r)
r = ApplyCellPadding(r);

// Convert our aspect to a numeric value
var aspect = (RatingEntry) Aspect;
var aspect = (RatingEntry) (Aspect ?? false);
Copy link
Owner

Choose a reason for hiding this comment

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

This will throw an invalid cast exception.

@@ -43,7 +43,7 @@ public override void Render(Graphics g, Rectangle r)
// Calculate how many images we need to draw to represent our aspect value
int numberOfImages;
if (aspectValue <= _minimumValue) numberOfImages = 1;
else if (aspectValue <= (_maximumValue + _minimumValue)/2) numberOfImages = 2;
else if (aspectValue <= (float) (_maximumValue + _minimumValue) / 2) numberOfImages = 2;
Copy link
Owner

Choose a reason for hiding this comment

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

I believe the clamping is intentional.

@@ -48,7 +48,7 @@ private void SearcherOnHoveredWindowChanged(object sender, WindowHoverEventArgs
{
label1.Text = windowHoverEventArgs.TargetWindow.WindowText;
label2.Text = windowHoverEventArgs.TargetWindow.WindowRect.ToString();
label3.Text = windowHoverEventArgs.TargetWindow.GetRunningProcess().MainModule.FileName;
label3.Text = windowHoverEventArgs.TargetWindow?.GetRunningProcess().MainModule.FileName;
Copy link
Owner

Choose a reason for hiding this comment

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

This can never be null.

info = this.ListView.OlvHitTest(pt.X, pt.Y - SMALL_VALUE);
if (info.Item != null) {
targetIndex = info.Item.Index;
if (info.Item != null)
Copy link
Owner

Choose a reason for hiding this comment

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

This should never be null.

@@ -193,7 +193,7 @@ private void RefreshSelectedFilter()
var item = listView1.SelectedItems[0];
var tag = CurrentlySelected;

item.SubItems[0].Text = tag.Name;
item.SubItems[0].Text = tag?.Name;
Copy link
Owner

Choose a reason for hiding this comment

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

With the check added this will throw a nullreference below instead.

@@ -128,7 +128,7 @@ IEnumerable<DirectoryInfo> FindDirsOnDrive(DriveInfo d)
{
try
{
return x.GetDirectories();
return x?.GetDirectories();
Copy link
Owner

Choose a reason for hiding this comment

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

This can never be null.

@@ -14,7 +14,7 @@ public void AddMissingInformation(ApplicationUninstallerEntry target)
{
if (target.UninstallerKind != UninstallerType.Steam || !SteamFactory.SteamHelperIsAvailable) return;

var appId = target.RatingId.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Last();
var appId = target?.RatingId.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Last();
Copy link
Owner

Choose a reason for hiding this comment

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

This can never be null.

@@ -80,7 +80,7 @@ private static void ApplyMsiInfo(ApplicationUninstallerEntry entry, Guid guid)
if (!temp.IsNotEmpty()) return;
try
{
entry.InstallDate = new DateTime(int.Parse(temp.Substring(0, 4)),
entry.InstallDate = new DateTime(int.Parse(temp?.Substring(0, 4)),
Copy link
Owner

Choose a reason for hiding this comment

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

This can never be null.

Klocman added a commit that referenced this pull request Aug 8, 2022
Includes null check from #378
@Klocman
Copy link
Owner

Klocman commented Aug 8, 2022

I added fixes to confirmed issues in separate commits, so I'll be closing the PR now. Thank you for finding these.

@Klocman Klocman closed this Aug 8, 2022
@GermanAizek
Copy link
Author

@Klocman, ok. Thx for contribution!

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.

2 participants