Skip to content

Commit

Permalink
Fixing random warnings; Added more null checks and logging; Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Klocman committed Aug 9, 2022
1 parent 28cabfe commit c5943ef
Show file tree
Hide file tree
Showing 137 changed files with 413 additions and 707 deletions.
4 changes: 2 additions & 2 deletions source/BCU-console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static int ProcessListCommand(string[] args)
source = source.Substring(0, 40);
}

Console.WriteLine($"{displayName,-40} {version,-20} {source,-40}");
Console.WriteLine($@"{displayName,-40} {version,-20} {source,-40}");
}
return 0;
}
Expand Down Expand Up @@ -197,7 +197,7 @@ private static int RunUninstall(UninstallList list, bool isQuiet, bool isUnatten
return 0;
}

Console.WriteLine("{0} application(s) were matched by the list: {1}", apps.Count,
Console.WriteLine(@"{0} application(s) were matched by the list: {1}", apps.Count,
string.Join("; ", apps.Select(x => x.DisplayName)));

Console.WriteLine(@"These applications will now be uninstalled PERMANENTLY.");
Expand Down
37 changes: 0 additions & 37 deletions source/BCU-launcher/TestConsole.vcxproj.filters

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeEditing/Localization/Localizable/@EntryValue">No</s:String>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=controls_005Csettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=forms_005Chelpers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=forms_005Cwindows/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=forms_005Cwizards/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
2 changes: 1 addition & 1 deletion source/BulkCrapUninstaller/Controls/ListLegend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ListLegend()
InitializeComponent();
}

protected override void OnLoad(System.EventArgs e)
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public AdvancedFilters()
InitializeComponent();
}

protected override void OnLoad(System.EventArgs e)
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

Expand Down
4 changes: 0 additions & 4 deletions source/BulkCrapUninstaller/Controls/Settings/CacheSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
Apache License Version 2.0
*/

using System;
using System.Windows.Forms;
using BulkCrapUninstaller.Forms;
using Klocman.Binding.Settings;
using Klocman.Forms.Tools;
using UninstallTools;

namespace BulkCrapUninstaller.Controls.Settings
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,49 @@ public UninstallationSettings()
InitializeComponent();
}

protected override void OnLoad(System.EventArgs e)
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

if (DesignMode) return;

var settings = Properties.Settings.Default.SettingBinder;
var sb = Properties.Settings.Default.SettingBinder;

// Shutdown blocking not available below Windows Vista
if (Environment.OSVersion.Version < new Version(6, 0))
checkBoxShutdown.Enabled = false;
else
settings.BindControl(checkBoxShutdown, settings => settings.UninstallPreventShutdown, this);
sb.BindControl(checkBoxShutdown, settings => settings.UninstallPreventShutdown, this);

checkBoxRestorePoint.Enabled = SysRestore.SysRestoreAvailable();
settings.BindControl(checkBoxRestorePoint, settings => settings.CreateRestorePoint, this);
sb.BindControl(checkBoxRestorePoint, settings => settings.CreateRestorePoint, this);

settings.BindControl(checkBoxConcurrent, settings => settings.UninstallConcurrency, this);
sb.BindControl(checkBoxConcurrent, settings => settings.UninstallConcurrency, this);

settings.BindControl(checkBoxConcurrentOneLoud, settings => settings.UninstallConcurrentOneLoud, this);
settings.BindControl(checkBoxManualNoCollisionProtection, settings => settings.UninstallConcurrentDisableManualCollisionProtection, this);
sb.BindControl(checkBoxConcurrentOneLoud, settings => settings.UninstallConcurrentOneLoud, this);
sb.BindControl(checkBoxManualNoCollisionProtection, settings => settings.UninstallConcurrentDisableManualCollisionProtection, this);

settings.Subscribe(OnMaxCountChanged, settings => settings.UninstallConcurrentMaxCount, this);
sb.Subscribe(OnMaxCountChanged, settings => settings.UninstallConcurrentMaxCount, this);
numericUpDownMaxConcurrent.ValueChanged += NumericUpDownMaxConcurrentOnValueChanged;

settings.BindControl(checkBoxBatchSortQuiet, x => x.AdvancedIntelligentUninstallerSorting, this);
settings.BindControl(checkBoxDiisableProtection, x => x.AdvancedDisableProtection, this);
settings.BindControl(checkBoxSimulate, x => x.AdvancedSimulate, this);
sb.BindControl(checkBoxBatchSortQuiet, x => x.AdvancedIntelligentUninstallerSorting, this);
sb.BindControl(checkBoxDiisableProtection, x => x.AdvancedDisableProtection, this);
sb.BindControl(checkBoxSimulate, x => x.AdvancedSimulate, this);

settings.BindControl(checkBoxAutoKillQuiet, x => x.QuietAutoKillStuck, this);
settings.BindControl(checkBoxRetryQuiet, x => x.QuietRetryFailedOnce, this);
settings.BindControl(checkBoxGenerate, x => x.QuietAutomatization, this);
settings.BindControl(checkBoxGenerateStuck, x => x.QuietAutomatizationKillStuck, this);
settings.BindControl(checkBoxAutoDaemon, x => x.QuietUseDaemon, this);
sb.BindControl(checkBoxAutoKillQuiet, x => x.QuietAutoKillStuck, this);
sb.BindControl(checkBoxRetryQuiet, x => x.QuietRetryFailedOnce, this);
sb.BindControl(checkBoxGenerate, x => x.QuietAutomatization, this);
sb.BindControl(checkBoxGenerateStuck, x => x.QuietAutomatizationKillStuck, this);
sb.BindControl(checkBoxAutoDaemon, x => x.QuietUseDaemon, this);

settings.Subscribe((sender, args) => checkBoxGenerateStuck.Enabled = args.NewValue, settings => settings.QuietAutomatization, this);
sb.Subscribe((sender, args) => checkBoxGenerateStuck.Enabled = args.NewValue, settings => settings.QuietAutomatization, this);

settings.Subscribe(
sb.Subscribe(
(x, y) => checkBoxSimulate.ForeColor = y.NewValue ? Color.OrangeRed : SystemColors.ControlText,
x => x.AdvancedSimulate, this);

settings.SendUpdates(this);
Disposed += (x, y) => settings.RemoveHandlers(this);
sb.SendUpdates(this);
Disposed += (x, y) => sb.RemoveHandlers(this);
}

private void NumericUpDownMaxConcurrentOnValueChanged(object sender, EventArgs eventArgs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public class TabControlWithoutHeader : TabControl
{
public TabControlWithoutHeader()
{
if (!this.DesignMode) this.Multiline = true;
if (!DesignMode) Multiline = true;
}

protected override void WndProc(ref Message m)
{
if (m.Msg == 0x1328 && !this.DesignMode)
if (m.Msg == 0x1328 && !DesignMode)
m.Result = new IntPtr(1);
else
base.WndProc(ref m);
Expand Down
7 changes: 2 additions & 5 deletions source/BulkCrapUninstaller/CultureConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Klocman.Tools;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
Expand All @@ -16,11 +15,9 @@ public static class CultureConfigurator
private static IEnumerable<CultureInfo> _supportedLanguages;
private static CultureInfo _enUsCulture;

private static CultureInfo EnUsCulture =>
_enUsCulture ?? (_enUsCulture = CultureInfo.GetCultureInfo("en-US"));
private static CultureInfo EnUsCulture => _enUsCulture ??= CultureInfo.GetCultureInfo("en-US");

public static IEnumerable<CultureInfo> SupportedLanguages =>
_supportedLanguages ?? (_supportedLanguages = GetSupportedLanguages());
public static IEnumerable<CultureInfo> SupportedLanguages => _supportedLanguages ??= GetSupportedLanguages();

private static IEnumerable<CultureInfo> GetSupportedLanguages()
{
Expand Down
4 changes: 2 additions & 2 deletions source/BulkCrapUninstaller/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ private static void HandleBeingSecondInstance()
{
try
{
var location = Assembly.GetAssembly(typeof(EntryPoint)).Location;
var location = Assembly.GetAssembly(typeof(EntryPoint))!.Location;
if (location.EndsWith(".dll")) location = location.Substring(0, location.Length - 3) + "exe";
var otherBcu = Process.GetProcesses().FirstOrDefault(x =>
{
try
{
return string.Equals(x.MainModule.FileName, location, StringComparison.OrdinalIgnoreCase);
return string.Equals(x.MainModule!.FileName, location, StringComparison.OrdinalIgnoreCase);
}
catch
{
Expand Down
4 changes: 2 additions & 2 deletions source/BulkCrapUninstaller/Forms/Helpers/DebugWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal DebugWindow(MainWindow reference, UninstallerListViewUpdater listview,
var wr = new ComboBoxWrapper<MethodInfo>(x, y =>
{
var name = y.ToString();
return name.Substring(name.IndexOf(' ') + 1);
return name!.Substring(name.IndexOf(' ') + 1);
});
comboBoxMessages.Items.Add(wr);
}
Expand Down Expand Up @@ -159,7 +159,7 @@ private void checkBox2_CheckedChanged(object sender, EventArgs e)
private void TestCrashBackgroundThread(object sender, EventArgs e)
{
NBug.Settings.ReleaseMode = false;
new Thread(() => { throw new ArgumentException("TestCrashBackgroundThread", new IOException("Inner exception")); }).Start();
new Thread(() => throw new ArgumentException("TestCrashBackgroundThread", new IOException("Inner exception"))).Start();
}

private void TestCrashUiThread(object sender, EventArgs e)
Expand Down
6 changes: 3 additions & 3 deletions source/BulkCrapUninstaller/Forms/Helpers/FeedbackWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompl

try
{
var container = webBrowser.Document.GetElementById("container");
container.InnerHtml = webBrowser.Document.GetElementById("content").InnerHtml;
var container = webBrowser.Document!.GetElementById("container");
container!.InnerHtml = webBrowser.Document.GetElementById("content")!.InnerHtml;
container.Style = "width:422px; margin:10px auto; padding:10px; align:center;";
webBrowser.Document.Body.Style = "padding:0px;";
webBrowser.Document.Body!.Style = "padding:0px;";
}
catch
{
Expand Down
4 changes: 2 additions & 2 deletions source/BulkCrapUninstaller/Forms/Helpers/ListLegendWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public void UpdatePosition(Control owner)

public ListLegend ListLegend => listLegend1;

private void ListLegendWindow_VisibleChanged(object sender, System.EventArgs e)
private void ListLegendWindow_VisibleChanged(object sender, EventArgs e)
{
if (Opacity < .9)
opacityResetTimer.Start();
}

private void ListLegendWindow_EnabledChanged(object sender, System.EventArgs e)
private void ListLegendWindow_EnabledChanged(object sender, EventArgs e)
{
if (Opacity < .9)
opacityResetTimer.Start();
Expand Down
2 changes: 0 additions & 2 deletions source/BulkCrapUninstaller/Forms/Helpers/NewsPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
*/

using System;
using System.IO;
using System.Windows.Forms;
using BulkCrapUninstaller.Functions;
using BulkCrapUninstaller.Properties;
using Klocman.Forms.Tools;

namespace BulkCrapUninstaller.Forms
{
Expand Down
4 changes: 1 addition & 3 deletions source/BulkCrapUninstaller/Forms/Helpers/PropertiesWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ private void OnSelectedTabChanged(object sender, EventArgs e)
UseWaitCursor = true;
Application.DoEvents();

dataGridView1.DataSource =
Functions.AppPropertiesGatherer.GetInfo(tabControl1.SelectedTab.Tag as ApplicationUninstallerEntry,
CurrentlyVisiblePage);
dataGridView1.DataSource = AppPropertiesGatherer.GetInfo(tabControl1.SelectedTab.Tag as ApplicationUninstallerEntry, CurrentlyVisiblePage);

// Make first column shorter, since it contains much less text. Default FillWeight is around 34
var firstColumn = dataGridView1.Columns.GetFirstColumn(new DataGridViewElementStates());
Expand Down
4 changes: 2 additions & 2 deletions source/BulkCrapUninstaller/Forms/Helpers/TargetWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void WindowTargeterWindowSelected(object sender, Klocman.Subsystems.Wind
{
try
{
var parentDirectory = new FileInfo(e.TargetWindow.GetRunningProcess().MainModule.FileName).Directory;
var parentDirectory = new FileInfo(e.TargetWindow.GetRunningProcess().MainModule?.FileName ?? throw new InvalidOperationException("Process has no MainModule")).Directory;
OnDirectoriesSelected(new DirectoriesSelectedEventArgs(parentDirectory.ToEnumerable().ToList()));
}
catch (Exception exception)
Expand All @@ -62,7 +62,7 @@ private void WindowTargeterWindowSelected(object sender, Klocman.Subsystems.Wind
}
}

public new static ICollection<DirectoryInfo> ShowDialog(IWin32Window owner)
public static new ICollection<DirectoryInfo> ShowDialog(IWin32Window owner)
{
using (var window = new TargetWindow())
{
Expand Down
13 changes: 7 additions & 6 deletions source/BulkCrapUninstaller/Forms/Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ internal sealed partial class MainWindow : Form
private string MainTitleBarText { get; }

public static string CertificateCacheFilename { get; } = Path.Combine(Program.AssemblyLocation.FullName, "CertCache.xml");
public static CertificateCache CertificateCache { get; } = new CertificateCache(CertificateCacheFilename);
public static CertificateCache CertificateCache { get; } = new(CertificateCacheFilename);

private readonly UninstallerListViewUpdater _listView;
private readonly SettingTools _setMan;
private readonly WindowStyleController _styleController;
private readonly AppUninstaller _appUninstaller;
private readonly UninstallerListConfigurator _uninstallerListConfigurator;

private readonly ListLegendWindow _listLegendWindow = new ListLegendWindow();
private readonly ListLegendWindow _listLegendWindow = new();
private DebugWindow _debugWindow;

private bool _previousListLegendState = true;
Expand Down Expand Up @@ -202,8 +202,8 @@ protected override void OnDpiChanged(DpiChangedEventArgs e)

var scaleChange = e.DeviceDpiNew / (double)e.DeviceDpiOld;

this.toolStripLabelSize.Width = (int)Math.Round(toolStripLabelSize.Width * scaleChange);
this.toolStripLabelTotal.Width = (int)Math.Round(toolStripLabelTotal.Width * scaleChange);
toolStripLabelSize.Width = (int)Math.Round(toolStripLabelSize.Width * scaleChange);
toolStripLabelTotal.Width = (int)Math.Round(toolStripLabelTotal.Width * scaleChange);
}

protected override void OnFormClosed(FormClosedEventArgs e)
Expand All @@ -216,6 +216,7 @@ protected override void OnFormClosed(FormClosedEventArgs e)
_listLegendWindow?.Dispose();
_uninstallerListConfigurator?.Dispose();
_debugWindow?.Dispose();
_uninstallerListPostProcesser?.Dispose();
}
catch (Exception exception)
{
Expand Down Expand Up @@ -364,7 +365,7 @@ private void OnTreeMapSliceClicked(object sender, TreeMap.SliceClickedEventArgs

private void UpdateTreeMap(object sender, EventArgs args)
{
treeMap1.Populate(_listView.FilteredUninstallers.Cast<object>());
treeMap1.Populate(_listView.FilteredUninstallers);
}

private void OnApplicationListVisibleItemsChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -1822,7 +1823,7 @@ private void createRestorePointToolStripMenuItem_Click(object sender, EventArgs
LockApplication(true);
try
{
SystemRestore.BeginSysRestore(0, false, true, this);
SystemRestore.BeginSysRestore(0, false, this);
}
catch (Exception exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.Globalization;
using System.Linq;
using System.Media;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using BulkCrapUninstaller.Functions;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c5943ef

Please sign in to comment.