diff --git a/WSLDiskShrinker/Common/BooleanToInverseVisibilityConverter.cs b/WSLDiskShrinker/Common/BooleanToInverseVisibilityConverter.cs
index a999150..11b4104 100644
--- a/WSLDiskShrinker/Common/BooleanToInverseVisibilityConverter.cs
+++ b/WSLDiskShrinker/Common/BooleanToInverseVisibilityConverter.cs
@@ -5,15 +5,13 @@ namespace WSLDiskShrinker.Common;
class BooleanToInverseVisibilityConverter : IValueConverter
{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- bool v = (bool) value;
- return v ? Visibility.Collapsed : Visibility.Visible;
- }
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (bool)value ? Visibility.Collapsed : Visibility.Visible;
+ }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (bool)value ? Visibility.Visible : Visibility.Collapsed; // Not used.
+ }
}
-
diff --git a/WSLDiskShrinker/Common/BooleanToVisibilityConverter.cs b/WSLDiskShrinker/Common/BooleanToVisibilityConverter.cs
index 95ad297..998b881 100644
--- a/WSLDiskShrinker/Common/BooleanToVisibilityConverter.cs
+++ b/WSLDiskShrinker/Common/BooleanToVisibilityConverter.cs
@@ -5,15 +5,13 @@ namespace WSLDiskShrinker.Common;
class BooleanToVisibilityConverter : IValueConverter
{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- bool v = (bool)value;
- return v ? Visibility.Visible : Visibility.Collapsed;
- }
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (bool)value ? Visibility.Visible : Visibility.Collapsed;
+ }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (bool)value ? Visibility.Collapsed : Visibility.Visible; // Not used.
+ }
}
-
diff --git a/WSLDiskShrinker/Common/CommandFailedException.cs b/WSLDiskShrinker/Common/CommandFailedException.cs
index 9547d59..cd9b424 100644
--- a/WSLDiskShrinker/Common/CommandFailedException.cs
+++ b/WSLDiskShrinker/Common/CommandFailedException.cs
@@ -1,11 +1,21 @@
-namespace WSLDiskShrinker.Common;
+using System.Runtime.Serialization;
-public class CommandFailedException : Exception
+namespace WSLDiskShrinker.Common;
+
+[Serializable]
+public class CommandFailedException : Exception /* ISerializable */
{
- public Process FailedProcess { get; set; }
- public CommandFailedException(Process p)
- {
- this.FailedProcess = p;
- }
-}
+ public Process? FailedProcess { get; }
+ public CommandFailedException(Process p)
+ {
+ this.FailedProcess = p;
+ }
+ // Implement exception constructors (not used).
+ public CommandFailedException() : base() { }
+ public CommandFailedException(string? message) : base(message) { }
+ public CommandFailedException(string? message, Exception? innerException) : base(message, innerException) { }
+
+ // ISerializable should be implemented (not used).
+ protected CommandFailedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+}
diff --git a/WSLDiskShrinker/Common/NotConverter.cs b/WSLDiskShrinker/Common/NotConverter.cs
index a1c3b76..f833390 100644
--- a/WSLDiskShrinker/Common/NotConverter.cs
+++ b/WSLDiskShrinker/Common/NotConverter.cs
@@ -5,15 +5,13 @@ namespace WSLDiskShrinker.Common;
class NotConverter : IValueConverter
{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return !(bool)value;
+ }
- return !(bool)value;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return !(bool)value; // Not used.
+ }
}
-
diff --git a/WSLDiskShrinker/Common/ProcessExtension.cs b/WSLDiskShrinker/Common/ProcessExtension.cs
index bf6adc7..b6ace0d 100644
--- a/WSLDiskShrinker/Common/ProcessExtension.cs
+++ b/WSLDiskShrinker/Common/ProcessExtension.cs
@@ -1,29 +1,27 @@
-using System.Threading;
+#if !NET5_0_OR_GREATER
+
+using System.Threading;
namespace WSLDiskShrinker.Common;
// https://stackoverflow.com/questions/470256/process-waitforexit-asynchronously
static class ProcessExtension
{
- ///
- /// Waits asynchronously for the process to exit.
- ///
- /// The process to wait for cancellation.
- /// A cancellation token. If invoked, the task will return
- /// immediately as canceled.
- /// A Task representing waiting for the process to end.
- public static Task CustomWaitForExitAsync(this Process process,
- CancellationToken cancellationToken = default)
- {
- if (process.HasExited) return Task.CompletedTask;
+ /// Waits asynchronously for the process to exit.
+ /// The process to wait for cancellation.
+ /// A cancellation token. If invoked, the task will return immediately as canceled.
+ /// A Task representing waiting for the process to end.
+ public static Task CustomWaitForExitAsync(this Process process, CancellationToken cancellationToken = default)
+ {
+ if (process.HasExited) return Task.CompletedTask;
- var tcs = new TaskCompletionSource