瀏覽代碼

Take advantage of C# 7 language features

Antony Male 8 年之前
父節點
當前提交
c41b73485e
共有 70 個文件被更改,包括 310 次插入396 次删除
  1. 5 9
      src/SyncTrayzor/Bootstrapper.cs
  2. 2 8
      src/SyncTrayzor/Design/DummyFileTransfersTrayViewModel.cs
  3. 30 6
      src/SyncTrayzor/GlobalSuppressions.cs
  4. 3 8
      src/SyncTrayzor/Localization/CustomPluralLocalizationFormatter.cs
  5. 1 2
      src/SyncTrayzor/NotifyIcon/BalloonConductor.cs
  6. 2 6
      src/SyncTrayzor/NotifyIcon/ConnectedEventDebouncer.cs
  7. 6 7
      src/SyncTrayzor/NotifyIcon/NotifyIconManager.cs
  8. 1 4
      src/SyncTrayzor/Pages/AboutViewModel.cs
  9. 1 3
      src/SyncTrayzor/Pages/BarAlerts/BarAlertsViewModel.cs
  10. 1 2
      src/SyncTrayzor/Pages/ConflictResolution/ConflictResolutionViewModel.cs
  11. 0 4
      src/SyncTrayzor/Pages/ConflictResolution/MultipleConflictsResolutionViewModel.cs
  12. 1 12
      src/SyncTrayzor/Pages/ConflictResolution/SingleConflictResolutionViewModel.cs
  13. 12 17
      src/SyncTrayzor/Pages/FileTransfersTrayViewModel.cs
  14. 1 4
      src/SyncTrayzor/Pages/NewVersionInstalledToastViewModel.cs
  15. 7 11
      src/SyncTrayzor/Pages/Settings/SettingsViewModel.cs
  16. 1 2
      src/SyncTrayzor/Pages/Settings/SyncthingAddressValidator.cs
  17. 3 6
      src/SyncTrayzor/Pages/Settings/SyncthingCommandLineFlagsValidator.cs
  18. 3 6
      src/SyncTrayzor/Pages/Settings/SyncthingEnvironmentalVariablesValidator.cs
  19. 2 8
      src/SyncTrayzor/Pages/UnhandledExceptionViewModel.cs
  20. 7 6
      src/SyncTrayzor/Pages/ViewerViewModel.cs
  21. 4 10
      src/SyncTrayzor/Services/AlertsManager.cs
  22. 1 1
      src/SyncTrayzor/Services/ApplicationState.cs
  23. 2 4
      src/SyncTrayzor/Services/AutostartProvider.cs
  24. 4 4
      src/SyncTrayzor/Services/Config/Configuration.cs
  25. 2 7
      src/SyncTrayzor/Services/Config/ConfigurationProvider.cs
  26. 1 7
      src/SyncTrayzor/Services/Config/IconAnimationMode.cs
  27. 0 1
      src/SyncTrayzor/Services/ConfigurationApplicator.cs
  28. 2 4
      src/SyncTrayzor/Services/Conflicts/ConflictFileManager.cs
  29. 2 3
      src/SyncTrayzor/Services/Conflicts/ConflictFileWatcher.cs
  30. 0 4
      src/SyncTrayzor/Services/DonationManager.cs
  31. 1 3
      src/SyncTrayzor/Services/FileWatcher.cs
  32. 0 4
      src/SyncTrayzor/Services/Ipc/IpcCommsClientFactory.cs
  33. 2 2
      src/SyncTrayzor/Services/MemoryUsageLogger.cs
  34. 3 5
      src/SyncTrayzor/Services/Metering/MeteredNetworkManager.cs
  35. 1 2
      src/SyncTrayzor/Services/Metering/NetworkCostManager.cs
  36. 1 2
      src/SyncTrayzor/Services/UpdateManagement/UpdateDownloader.cs
  37. 3 2
      src/SyncTrayzor/Services/UpdateManagement/UpdateManager.cs
  38. 2 2
      src/SyncTrayzor/Services/UpdateManagement/UpdateNotificationResponse.cs
  39. 1 2
      src/SyncTrayzor/Services/UserActivityMonitor.cs
  40. 2 2
      src/SyncTrayzor/Services/WatchedFolderMonitor.cs
  41. 106 69
      src/SyncTrayzor/SyncTrayzor.ruleset
  42. 2 2
      src/SyncTrayzor/Syncthing/ApiClient/Config.cs
  43. 1 2
      src/SyncTrayzor/Syncthing/ApiClient/DeviceConnectedEvent.cs
  44. 1 2
      src/SyncTrayzor/Syncthing/ApiClient/EventConverter.cs
  45. 1 2
      src/SyncTrayzor/Syncthing/ApiClient/StartupCompleteEvent.cs
  46. 2 2
      src/SyncTrayzor/Syncthing/ApiClient/StateChangedEvent.cs
  47. 0 1
      src/SyncTrayzor/Syncthing/ApiClient/SyncthingHttpClientHandler.cs
  48. 2 2
      src/SyncTrayzor/Syncthing/Devices/Device.cs
  49. 3 6
      src/SyncTrayzor/Syncthing/Devices/SyncthingAddressParser.cs
  50. 9 22
      src/SyncTrayzor/Syncthing/Devices/SyncthingDeviceManager.cs
  51. 2 2
      src/SyncTrayzor/Syncthing/Folders/FolderError.cs
  52. 1 2
      src/SyncTrayzor/Syncthing/Folders/FolderStateTransformer.cs
  53. 6 14
      src/SyncTrayzor/Syncthing/Folders/SyncthingFolderManager.cs
  54. 6 6
      src/SyncTrayzor/Syncthing/SyncthingManager.cs
  55. 2 2
      src/SyncTrayzor/Syncthing/TransferHistory/FailingTransfer.cs
  56. 3 6
      src/SyncTrayzor/Syncthing/TransferHistory/SyncthingTransferHistory.cs
  57. 3 3
      src/SyncTrayzor/Syncthing/TransientWrapper.cs
  58. 2 7
      src/SyncTrayzor/Utils/AtomicFileStream.cs
  59. 1 2
      src/SyncTrayzor/Utils/DotNetVersionFinder.cs
  60. 1 4
      src/SyncTrayzor/Utils/LimitedConcurrencyTaskScheduler.cs
  61. 2 2
      src/SyncTrayzor/Utils/ShellTools.cs
  62. 0 2
      src/SyncTrayzor/Utils/StringExtensions.cs
  63. 4 2
      src/SyncTrayzor/Utils/UriExtensions.cs
  64. 2 2
      src/SyncTrayzor/Xaml/ActivateBehaviour.cs
  65. 6 6
      src/SyncTrayzor/Xaml/CollapsingRowDefinitionBehaviour.cs
  66. 1 2
      src/SyncTrayzor/Xaml/GridViewSortByBehaviour.cs
  67. 4 6
      src/SyncTrayzor/Xaml/PopupConductorBehaviour.cs
  68. 1 2
      src/SyncTrayzor/Xaml/TextBoxUtilities.cs
  69. 5 4
      src/SyncTrayzor/Xaml/UacImageSource.cs
  70. 8 8
      src/SyncTrayzor/Xaml/WindowPlacementBehaviour.cs

+ 5 - 9
src/SyncTrayzor/Bootstrapper.cs

@@ -155,7 +155,7 @@ namespace SyncTrayzor
                 autostartProvider.SetAutoStart(new AutostartConfiguration() { AutoStart = true, StartMinimized = true });
 
             // Needs to be done before ConfigurationApplicator is run
-            this.Container.Get<IApplicationWindowState>().Setup((ShellViewModel)this.RootViewModel);
+            this.Container.Get<IApplicationWindowState>().Setup(this.RootViewModel);
 
             this.Container.Get<ConfigurationApplicator>().ApplyConfiguration();
 
@@ -225,8 +225,7 @@ namespace SyncTrayzor
         {
             var logger = LogManager.GetCurrentClassLogger();
             logger.Error(e.Exception, "An unhandled exception occurred");
-            var typeLoadException = e.Exception as ReflectionTypeLoadException;
-            if (typeLoadException != null)
+            if (e.Exception is ReflectionTypeLoadException typeLoadException)
             {
                 logger.Error("Loader exceptions:");
                 foreach (var ex in typeLoadException.LoaderExceptions)
@@ -251,8 +250,7 @@ namespace SyncTrayzor
             {
                 var windowManager = this.Container.Get<IWindowManager>();
 
-                var couldNotFindSyncthingException = e.Exception as CouldNotFindSyncthingException;
-                if (couldNotFindSyncthingException != null)
+                if (e.Exception is CouldNotFindSyncthingException couldNotFindSyncthingException)
                 {
                     var msg = $"Could not find syncthing.exe at {couldNotFindSyncthingException.SyncthingPath}\n\nIf you deleted it manually, put it back. If an over-enthsiastic " +
                     "antivirus program quarantined it, restore it. If all else fails, download syncthing.exe from https://github.com/syncthing/syncthing/releases the put it " +
@@ -265,8 +263,7 @@ namespace SyncTrayzor
                     return;
                 }
 
-                var configurationException = e.Exception as BadConfigurationException;
-                if (configurationException != null)
+                if (e.Exception is BadConfigurationException configurationException)
                 {
                     var inner = configurationException.InnerException.Message;
                     if (configurationException.InnerException.InnerException != null)
@@ -284,8 +281,7 @@ namespace SyncTrayzor
                     return;
                 }
 
-                var couldNotSaveConfigurationException = e.Exception as CouldNotSaveConfigurationExeption;
-                if (couldNotSaveConfigurationException != null)
+                if (e.Exception is CouldNotSaveConfigurationExeption couldNotSaveConfigurationException)
                 {
                     var msg = $"Could not save configuration file.\n\n" +
                         $"{couldNotSaveConfigurationException.InnerException.GetType().Name}: {couldNotSaveConfigurationException.InnerException.Message}.\n\n" +

+ 2 - 8
src/SyncTrayzor/Design/DummyFileTransfersTrayViewModel.cs

@@ -10,14 +10,8 @@ namespace SyncTrayzor.Design
         public BindableCollection<FileTransferViewModel> CompletedTransfers { get; private set; }
         public BindableCollection<FileTransferViewModel> InProgressTransfers { get; private set; }
 
-        public bool HasCompletedTransfers
-        {
-            get { return this.CompletedTransfers.Count > 0; }
-        }
-        public bool HasInProgressTransfers
-        {
-            get { return this.InProgressTransfers.Count > 0; }
-        }
+        public bool HasCompletedTransfers => this.CompletedTransfers.Count > 0;
+        public bool HasInProgressTransfers => this.InProgressTransfers.Count > 0;
 
         public string InConnectionRate { get; private set; }
         public string OutConnectionRate { get; private set; }

+ 30 - 6
src/SyncTrayzor/GlobalSuppressions.cs

@@ -4,9 +4,33 @@
 // Project-level suppressions either have no target or are given 
 // a specific target and scoped to a namespace, type, member, etc.
 
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0016:Use 'throw' expression", Justification = "<Pending>", Scope = "member", Target = "~M:Mono.Options.OptionSet.ActionOption.#ctor(System.String,System.String,System.Int32,System.Action{Mono.Options.OptionValueCollection},System.Boolean)")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0016:Use 'throw' expression", Justification = "<Pending>", Scope = "member", Target = "~M:Mono.Options.OptionSet.ActionOption`1.#ctor(System.String,System.String,System.Action{`0})")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0016:Use 'throw' expression", Justification = "<Pending>", Scope = "member", Target = "~M:Mono.Options.OptionSet.ActionOption`2.#ctor(System.String,System.String,Mono.Options.OptionAction{`0,`1})")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0018:Inline variable declaration", Justification = "<Pending>", Scope = "member", Target = "~M:Mono.Options.OptionSet.AddSource(Mono.Options.OptionSet.ArgumentEnumerator,System.String)~System.Boolean")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0018:Inline variable declaration", Justification = "<Pending>", Scope = "member", Target = "~M:Mono.Options.OptionSet.Parse(System.String,Mono.Options.OptionContext)~System.Boolean")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0019:Use pattern matching", Justification = "<Pending>", Scope = "member", Target = "~M:Mono.Options.OptionSet.WriteOptionDescriptions(System.IO.TextWriter)")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0016:Use 'throw' expression", Justification = "Imported Code", Scope = "member", Target = "~M:Mono.Options.OptionSet.ActionOption.#ctor(System.String,System.String,System.Int32,System.Action{Mono.Options.OptionValueCollection},System.Boolean)")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0016:Use 'throw' expression", Justification = "Imported Code", Scope = "member", Target = "~M:Mono.Options.OptionSet.ActionOption`1.#ctor(System.String,System.String,System.Action{`0})")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0016:Use 'throw' expression", Justification = "Imported Code", Scope = "member", Target = "~M:Mono.Options.OptionSet.ActionOption`2.#ctor(System.String,System.String,Mono.Options.OptionAction{`0,`1})")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0018:Inline variable declaration", Justification = "Imported Code", Scope = "member", Target = "~M:Mono.Options.OptionSet.AddSource(Mono.Options.OptionSet.ArgumentEnumerator,System.String)~System.Boolean")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0018:Inline variable declaration", Justification = "Imported Code", Scope = "member", Target = "~M:Mono.Options.OptionSet.Parse(System.String,Mono.Options.OptionContext)~System.Boolean")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0019:Use pattern matching", Justification = "Imported Code", Scope = "member", Target = "~M:Mono.Options.OptionSet.WriteOptionDescriptions(System.IO.TextWriter)")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0010:Add missing cases", Justification = "Imported Code", Scope = "member", Target = "~M:Mono.Options.OptionSet.Parse(System.String,Mono.Options.OptionContext)~System.Boolean")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.Option.Description")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.Option.Hidden")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.Option.MaxValueCount")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.Option.Names")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.Option.OptionValueType")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.Option.Prototype")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.Option.ValueSeparators")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0027:Use expression body for accessors", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionContext.Option")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0027:Use expression body for accessors", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionContext.OptionIndex")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0027:Use expression body for accessors", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionContext.OptionName")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionContext.OptionSet")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionContext.OptionValues")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionException.OptionName")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionSet.ArgumentSources")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionSet.MessageLocalizer")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionValueCollection.Count")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionValueCollection.IsReadOnly")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0027:Use expression body for accessors", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionValueCollection.Item(System.Int32)")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionValueCollection.System#Collections#ICollection#IsSynchronized")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionValueCollection.System#Collections#ICollection#SyncRoot")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionValueCollection.System#Collections#IList#IsFixedSize")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0027:Use expression body for accessors", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.OptionValueCollection.System#Collections#IList#Item(System.Int32)")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0025:Use expression body for properties", Justification = "Imported Code", Scope = "member", Target = "~P:Mono.Options.ResponseFileSource.Description")]

+ 3 - 8
src/SyncTrayzor/Localization/CustomPluralLocalizationFormatter.cs

@@ -10,8 +10,7 @@ namespace SyncTrayzor.Localization
 {
     public class CustomPluralLocalizationFormatter : IFormatter
     {
-        private string[] names = { "plural", "p", "" };
-        public string[] Names { get { return names; } set { names = value; } }
+        public string[] Names { get; set; } = { "plural", "p", "" };
 
         /// <summary>
         /// Initializes the plugin with rules for many common languages.
@@ -27,10 +26,7 @@ namespace SyncTrayzor.Localization
         private string defaultTwoLetterISOLanguageName;
         public string DefaultTwoLetterISOLanguageName
         {
-            get
-            {
-                return this.defaultTwoLetterISOLanguageName;
-            }
+            get => this.defaultTwoLetterISOLanguageName;
             set
             {
                 this.defaultTwoLetterISOLanguageName = value;
@@ -59,8 +55,7 @@ namespace SyncTrayzor.Localization
             }
 
             // Use the CultureInfo, if provided:
-            var cultureInfo = provider as CultureInfo;
-            if (cultureInfo != null)
+            if (provider is CultureInfo cultureInfo)
             {
                 var culturePluralRule = PluralRules.GetPluralRule(cultureInfo.TwoLetterISOLanguageName);
                 return culturePluralRule;

+ 1 - 2
src/SyncTrayzor/NotifyIcon/BalloonConductor.cs

@@ -18,8 +18,7 @@ namespace SyncTrayzor.NotifyIcon
             this.view = view;
             this.tcs = tcs;
 
-            var childAsIChild = this.child as IChild;
-            if (childAsIChild != null)
+            if (this.child is IChild childAsIChild)
                 childAsIChild.Parent = this;
         }
 

+ 2 - 6
src/SyncTrayzor/NotifyIcon/ConnectedEventDebouncer.cs

@@ -1,7 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 using SyncTrayzor.Syncthing.Devices;
@@ -35,8 +33,7 @@ namespace SyncTrayzor.NotifyIcon
 
             lock (this.syncRoot)
             {
-                CancellationTokenSource existingCts;
-                if (this.pendingDeviceIds.TryGetValue(device, out existingCts))
+                if (this.pendingDeviceIds.TryGetValue(device, out var existingCts))
                 {
                     // It already exists. Cancel it, restart.
                     existingCts.Cancel();
@@ -78,8 +75,7 @@ namespace SyncTrayzor.NotifyIcon
         {
             lock (this.syncRoot)
             {
-                CancellationTokenSource cts;
-                if (this.pendingDeviceIds.TryGetValue(device, out cts))
+                if (this.pendingDeviceIds.TryGetValue(device, out var cts))
                 {
                     cts.Cancel();
                     this.pendingDeviceIds.Remove(device);

+ 6 - 7
src/SyncTrayzor/NotifyIcon/NotifyIconManager.cs

@@ -51,7 +51,7 @@ namespace SyncTrayzor.NotifyIcon
         private bool _showOnlyOnClose;
         public bool ShowOnlyOnClose
         {
-            get { return this._showOnlyOnClose; }
+            get => this._showOnlyOnClose;
             set
             {
                 this._showOnlyOnClose = value;
@@ -64,7 +64,7 @@ namespace SyncTrayzor.NotifyIcon
         private bool _closeToTray;
         public bool CloseToTray
         {
-            get { return this._closeToTray; }
+            get => this._closeToTray;
             set { this._closeToTray = value; this.SetShutdownMode(); }
         }
 
@@ -182,8 +182,7 @@ namespace SyncTrayzor.NotifyIcon
             if (e.FileTransfers.All(x => x.Error != null && !x.IsNewError))
                 return;
 
-            bool notificationsEnabled;
-            if (this.FolderNotificationsEnabled != null && this.FolderNotificationsEnabled.TryGetValue(e.Folder.FolderId, out notificationsEnabled) && notificationsEnabled)
+            if (this.FolderNotificationsEnabled != null && this.FolderNotificationsEnabled.TryGetValue(e.Folder.FolderId, out bool notificationsEnabled) && notificationsEnabled)
             {
                 if (e.FileTransfers.Count == 0)
                 {
@@ -200,7 +199,7 @@ namespace SyncTrayzor.NotifyIcon
                     var fileTransfer = e.FileTransfers[0];
                     string msg = null;
                     if (fileTransfer.Error == null)
-                    { 
+                    {
                         if (fileTransfer.ActionType == ItemChangedActionType.Update)
                             msg = Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_UpdatedSingleFile, e.Folder.Label, Path.GetFileName(fileTransfer.Path));
                         else if (fileTransfer.ActionType == ItemChangedActionType.Delete)
@@ -235,7 +234,7 @@ namespace SyncTrayzor.NotifyIcon
                         else
                             messageParts.Add(Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_UpdatedFile, updates.Length));
                     }
-                        
+
 
                     if (deletes.Length > 0)
                     {
@@ -245,7 +244,7 @@ namespace SyncTrayzor.NotifyIcon
                         else
                             messageParts.Add(Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_DeletedFile, deletes.Length));
                     }
-                        
+
                     var text = Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_Multiple, e.Folder.Label, messageParts);
 
                     this.taskbarIcon.HideBalloonTip();

+ 1 - 4
src/SyncTrayzor/Pages/AboutViewModel.cs

@@ -24,10 +24,7 @@ namespace SyncTrayzor.Pages
         public string HomepageUrl { get; set; }
 
         public string NewerVersion { get; set; }
-        public bool ShowTranslatorAttributation
-        {
-            get { return Localizer.Translate("TranslatorAttributation") == Localizer.OriginalTranslation("TranslatorAttributation"); }
-        }
+        public bool ShowTranslatorAttributation => Localizer.Translate("TranslatorAttributation") == Localizer.OriginalTranslation("TranslatorAttributation");
         private string newerVersionDownloadUrl;
 
         public IDonationManager DonationManager { get; }

+ 1 - 3
src/SyncTrayzor/Pages/BarAlerts/BarAlertsViewModel.cs

@@ -2,7 +2,6 @@
 using SyncTrayzor.Pages.ConflictResolution;
 using SyncTrayzor.Services;
 using SyncTrayzor.Syncthing;
-using SyncTrayzor.Syncthing.Devices;
 using System;
 using System.Collections.Generic;
 
@@ -63,8 +62,7 @@ namespace SyncTrayzor.Pages.BarAlerts
                 var pausedDeviceNames = new List<string>();
                 foreach (var deviceId in pausedDeviceIds)
                 {
-                    Device device;
-                    if (this.syncthingManager.Devices.TryFetchById(deviceId, out device))
+                    if (this.syncthingManager.Devices.TryFetchById(deviceId, out var device))
                         pausedDeviceNames.Add(device.Name);
                 }
 

+ 1 - 2
src/SyncTrayzor/Pages/ConflictResolution/ConflictResolutionViewModel.cs

@@ -210,8 +210,7 @@ namespace SyncTrayzor.Pages.ConflictResolution
         public void ListViewDoubleClick(object sender, RoutedEventArgs e)
         {
             // Check that we were called on a row, not on a header
-            var vm = (e.OriginalSource as FrameworkElement)?.DataContext as ConflictViewModel;
-            if (vm != null)
+            if ((e.OriginalSource as FrameworkElement)?.DataContext is ConflictViewModel vm)
                 this.ShowFileInFolder(vm);
         }
 

+ 0 - 4
src/SyncTrayzor/Pages/ConflictResolution/MultipleConflictsResolutionViewModel.cs

@@ -1,10 +1,6 @@
 using Stylet;
 using SyncTrayzor.Utils;
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace SyncTrayzor.Pages.ConflictResolution
 {

+ 1 - 12
src/SyncTrayzor/Pages/ConflictResolution/SingleConflictResolutionViewModel.cs

@@ -1,15 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Stylet;
-using SyncTrayzor.Services;
-using SyncTrayzor.Services.Conflicts;
-using System.IO;
-using SyncTrayzor.Localization;
-using SyncTrayzor.Properties;
-using System.Windows;
+using Stylet;
 
 namespace SyncTrayzor.Pages.ConflictResolution
 {

+ 12 - 17
src/SyncTrayzor/Pages/FileTransfersTrayViewModel.cs

@@ -4,7 +4,6 @@ using SyncTrayzor.Properties;
 using SyncTrayzor.Services;
 using SyncTrayzor.Syncthing;
 using SyncTrayzor.Syncthing.ApiClient;
-using SyncTrayzor.Syncthing.Folders;
 using SyncTrayzor.Syncthing.TransferHistory;
 using SyncTrayzor.Utils;
 using System;
@@ -87,14 +86,20 @@ namespace SyncTrayzor.Pages
                             FormatUtils.BytesToHuman(this.FileTransfer.BytesTransferred),
                             FormatUtils.BytesToHuman(this.FileTransfer.TotalBytes));
                     }
-                    
-                    this.ProgressPercent = ((float)this.FileTransfer.BytesTransferred / (float)this.FileTransfer.TotalBytes) * 100;
+
+                    this.ProgressPercent = ((float)this.FileTransfer.BytesTransferred / this.FileTransfer.TotalBytes) * 100;
                     break;
 
                 case FileTransferStatus.Completed:
                     this.ProgressPercent = 100;
                     this.ProgressString = null;
                     break;
+
+                case FileTransferStatus.Started:
+                    break;
+
+                default:
+                    break;
             }
 
             this.Error = this.FileTransfer.Error;
@@ -111,22 +116,13 @@ namespace SyncTrayzor.Pages
         public BindableCollection<FileTransferViewModel> CompletedTransfers { get; private set; }
         public BindableCollection<FileTransferViewModel> InProgressTransfers { get; private set; }
 
-        public bool HasCompletedTransfers
-        {
-            get { return this.CompletedTransfers.Count > 0; }
-        }
-        public bool HasInProgressTransfers
-        {
-            get { return this.InProgressTransfers.Count > 0; }
-        }
+        public bool HasCompletedTransfers => this.CompletedTransfers.Count > 0;
+        public bool HasInProgressTransfers => this.InProgressTransfers.Count > 0;
 
         public string InConnectionRate { get; private set; }
         public string OutConnectionRate { get; private set; }
 
-        public bool AnyTransfers
-        {
-            get { return this.HasCompletedTransfers || this.HasInProgressTransfers; }
-        }
+        public bool AnyTransfers => this.HasCompletedTransfers || this.HasInProgressTransfers;
 
         public FileTransfersTrayViewModel(ISyncthingManager syncthingManager, IProcessStartProvider processStartProvider)
         {
@@ -215,8 +211,7 @@ namespace SyncTrayzor.Pages
         public void ItemClicked(FileTransferViewModel fileTransferVm)
         {
             var fileTransfer = fileTransferVm.FileTransfer;
-            Folder folder;
-            if (!this.syncthingManager.Folders.TryFetchById(fileTransfer.FolderId, out folder))
+            if (!this.syncthingManager.Folders.TryFetchById(fileTransfer.FolderId, out var folder))
                 return; // Huh? Nothing we can do about it...
 
             // Not sure of the best way to deal with deletions yet...

+ 1 - 4
src/SyncTrayzor/Pages/NewVersionInstalledToastViewModel.cs

@@ -6,9 +6,6 @@ namespace SyncTrayzor.Pages
     public class NewVersionInstalledToastViewModel : Screen
     {
         public Version Version { get; set; }
-        public string VersionString
-        {
-            get { return this.Version.ToString(3); }
-        }
+        public string VersionString => this.Version.ToString(3);
     }
 }

+ 7 - 11
src/SyncTrayzor/Pages/Settings/SettingsViewModel.cs

@@ -12,7 +12,6 @@ using System.Linq.Expressions;
 using System.Windows;
 using System.IO;
 using SyncTrayzor.Services.Metering;
-using SyncTrayzor.Syncthing.Folders;
 
 namespace SyncTrayzor.Pages.Settings
 {
@@ -161,8 +160,7 @@ namespace SyncTrayzor.Pages.Settings
                 x => String.Join(" ", x.SyncthingCommandLineFlags),
                 (x, v) =>
                 {
-                    IEnumerable<KeyValuePair<string, string>> envVars;
-                    KeyValueStringParser.TryParse(v, out envVars, mustHaveValue: false);
+                    KeyValueStringParser.TryParse(v, out var envVars, mustHaveValue: false);
                     x.SyncthingCommandLineFlags = envVars.Select(item => KeyValueStringParser.FormatItem(item.Key, item.Value)).ToList();
                 }, new SyncthingCommandLineFlagsValidator());
             this.SyncthingCommandLineFlags.RequiresSyncthingRestart = true;
@@ -171,8 +169,7 @@ namespace SyncTrayzor.Pages.Settings
                 x => KeyValueStringParser.Format(x.SyncthingEnvironmentalVariables),
                 (x, v) =>
                 {
-                    IEnumerable<KeyValuePair<string, string>> envVars;
-                    KeyValueStringParser.TryParse(v, out envVars);
+                    KeyValueStringParser.TryParse(v, out var envVars);
                     x.SyncthingEnvironmentalVariables = new EnvironmentalVariableCollection(envVars);
                 }, new SyncthingEnvironmentalVariablesValidator());
             this.SyncthingEnvironmentalVariables.RequiresSyncthingRestart = true;
@@ -198,10 +195,10 @@ namespace SyncTrayzor.Pages.Settings
 
             this.PriorityLevels = new BindableCollection<LabelledValue<SyncthingPriorityLevel>>()
             {
-                LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_AboveNormal, SyncTrayzor.Services.Config.SyncthingPriorityLevel.AboveNormal),
-                LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_Normal, SyncTrayzor.Services.Config.SyncthingPriorityLevel.Normal),
-                LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_BelowNormal, SyncTrayzor.Services.Config.SyncthingPriorityLevel.BelowNormal),
-                LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_Idle, SyncTrayzor.Services.Config.SyncthingPriorityLevel.Idle),
+                LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_AboveNormal, Services.Config.SyncthingPriorityLevel.AboveNormal),
+                LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_Normal, Services.Config.SyncthingPriorityLevel.Normal),
+                LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_BelowNormal, Services.Config.SyncthingPriorityLevel.BelowNormal),
+                LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_Idle, Services.Config.SyncthingPriorityLevel.Idle),
             };
 
             this.Bind(s => s.AreAllFoldersNotified, (o, e) =>
@@ -267,8 +264,7 @@ namespace SyncTrayzor.Pages.Settings
 
             var folderSettings = configuration.Folders.Select(x =>
             {
-                Folder folder;
-                this.syncthingManager.Folders.TryFetchById(x.ID, out folder);
+                this.syncthingManager.Folders.TryFetchById(x.ID, out var folder);
 
                 return new FolderSettings()
                 {

+ 1 - 2
src/SyncTrayzor/Pages/Settings/SyncthingAddressValidator.cs

@@ -16,8 +16,7 @@ namespace SyncTrayzor.Pages.Settings
                     return false;
 
                 str = "http://" + str;
-                Uri uri;
-                return Uri.TryCreate(str, UriKind.Absolute, out uri) && uri.IsWellFormedOriginalString() && uri.PathAndQuery == "/" && uri.Fragment == "";
+                return Uri.TryCreate(str, UriKind.Absolute, out var uri) && uri.IsWellFormedOriginalString() && uri.PathAndQuery == "/" && uri.Fragment == "";
             }).WithMessage(Resources.SettingsView_Validation_InvalidUrl);
         }
     }

+ 3 - 6
src/SyncTrayzor/Pages/Settings/SyncthingCommandLineFlagsValidator.cs

@@ -1,5 +1,4 @@
-using System.Collections.Generic;
-using System.Linq;
+using System.Linq;
 using FluentValidation;
 using FluentValidation.Results;
 using SyncTrayzor.Localization;
@@ -16,8 +15,7 @@ namespace SyncTrayzor.Pages.Settings
         {
             RuleFor(x => x.Value).Must(str =>
             {
-                IEnumerable<KeyValuePair<string, string>> result;
-                return KeyValueStringParser.TryParse(str, out result, mustHaveValue: false);
+                return KeyValueStringParser.TryParse(str, out var result, mustHaveValue: false);
             }).WithMessage(Resources.SettingsView_Validation_SyncthingCommandLineFlagsMustHaveFormat);
 
             RuleFor(x => x.Value).SetValidator(new IndividualFlagsValidator());
@@ -29,8 +27,7 @@ namespace SyncTrayzor.Pages.Settings
             {
                 Custom(str =>
                 {
-                    IEnumerable<KeyValuePair<string, string>> result;
-                    KeyValueStringParser.TryParse(str, out result, mustHaveValue: false);
+                    KeyValueStringParser.TryParse(str, out var result, mustHaveValue: false);
 
                     if (!result.All(flag => flag.Key.StartsWith("-")))
                         return new ValidationFailure(null, Resources.SettingsView_Validation_SyncthingCommandLineFlagsMustBeginWithHyphen);

+ 3 - 6
src/SyncTrayzor/Pages/Settings/SyncthingEnvironmentalVariablesValidator.cs

@@ -1,5 +1,4 @@
-using System.Collections.Generic;
-using System.Linq;
+using System.Linq;
 using FluentValidation;
 using SyncTrayzor.Properties;
 
@@ -11,14 +10,12 @@ namespace SyncTrayzor.Pages.Settings
         {
             RuleFor(x => x.Value).Must(str =>
             {
-                IEnumerable<KeyValuePair<string, string>> result;
-                return KeyValueStringParser.TryParse(str, out result);
+                return KeyValueStringParser.TryParse(str, out var result);
             }).WithMessage(Resources.SettingsView_Validation_SyncthingEnvironmentalVariablesMustHaveFormat);
 
             RuleFor(x => x.Value).Must(str =>
             {
-                IEnumerable<KeyValuePair<string, string>> result;
-                KeyValueStringParser.TryParse(str, out result);
+                KeyValueStringParser.TryParse(str, out var result);
                 return !result.Any(x => x.Key == "STTRACE");
             }).WithMessage(Resources.SettingsView_Validation_SetSttraceInTab);
         }

+ 2 - 8
src/SyncTrayzor/Pages/UnhandledExceptionViewModel.cs

@@ -18,14 +18,8 @@ namespace SyncTrayzor.Pages
 
         public string IssuesUrl { get; }
 
-        public string ErrorMessage
-        {
-            get { return this.GenerateErrorMessage(); }
-        }
-        public Icon Icon
-        {
-            get { return SystemIcons.Error; }
-        }
+        public string ErrorMessage => this.GenerateErrorMessage();
+        public Icon Icon => SystemIcons.Error;
 
         public UnhandledExceptionViewModel(IApplicationPathsProvider applicationPathsProvider, IProcessStartProvider processStartProvider, IAssemblyProvider assemblyProvider)
         {

+ 7 - 6
src/SyncTrayzor/Pages/ViewerViewModel.cs

@@ -9,7 +9,7 @@ using SyncTrayzor.Services.Config;
 using System.Threading;
 using SyncTrayzor.Services;
 using SyncTrayzor.Properties;
-using SyncTrayzor.Syncthing.Folders;
+
 using Microsoft.WindowsAPICodePack.Dialogs;
 
 namespace SyncTrayzor.Pages
@@ -28,7 +28,7 @@ namespace SyncTrayzor.Pages
 
         public string Location
         {
-            get { return this.WebBrowser?.Address; }
+            get => this.WebBrowser?.Address;
             private set
             {
                 if (this.WebBrowser != null)
@@ -259,8 +259,7 @@ namespace SyncTrayzor.Pages
 
         private void OpenFolder(string folderId)
         {
-            Folder folder;
-            if (!this.syncthingManager.Folders.TryFetchById(folderId, out folder))
+            if (!this.syncthingManager.Folders.TryFetchById(folderId, out var folder))
                 return;
 
             this.processStartProvider.ShowFolderInExplorer(folder.Path);
@@ -310,8 +309,10 @@ namespace SyncTrayzor.Pages
         {
             // SyncthingManager will always request over HTTPS, whether Syncthing enforces this or not.
             // However in an attempt to avoid #201 we'll use HTTP if available, and if not Syncthing will redirect us.
-            var uriBuilder = new UriBuilder(this.syncthingManager.Address.NormalizeZeroHost());
-            uriBuilder.Scheme = "http";
+            var uriBuilder = new UriBuilder(this.syncthingManager.Address.NormalizeZeroHost())
+            {
+                Scheme = "http"
+            };
             return uriBuilder.Uri;
         }
 

+ 4 - 10
src/SyncTrayzor/Services/AlertsManager.cs

@@ -35,16 +35,10 @@ namespace SyncTrayzor.Services
 
 
         private IReadOnlyList<string> _conflictedFiles = EmptyReadOnlyList<string>.Instance;
-        public IReadOnlyList<string> ConflictedFiles
-        {
-            get { return this._enableConflictedFileAlerts ? this._conflictedFiles : EmptyReadOnlyList<string>.Instance; }
-        }
+        public IReadOnlyList<string> ConflictedFiles => this._enableConflictedFileAlerts ? this._conflictedFiles : EmptyReadOnlyList<string>.Instance;
 
         private IReadOnlyList<string> _foldersWithFailedTransferFiles = EmptyReadOnlyList<string>.Instance;
-        public IReadOnlyList<string> FoldersWithFailedTransferFiles
-        {
-            get { return this._enableFailedTransferAlerts ? this._foldersWithFailedTransferFiles : EmptyReadOnlyList<string>.Instance; }
-        }
+        public IReadOnlyList<string> FoldersWithFailedTransferFiles => this._enableFailedTransferAlerts ? this._foldersWithFailedTransferFiles : EmptyReadOnlyList<string>.Instance;
 
         public IReadOnlyList<string> PausedDeviceIdsFromMetering { get; private set; } = EmptyReadOnlyList<string>.Instance;
 
@@ -53,7 +47,7 @@ namespace SyncTrayzor.Services
         private bool _enableFailedTransferAlerts;
         public bool EnableFailedTransferAlerts
         {
-            get { return this._enableFailedTransferAlerts; }
+            get => this._enableFailedTransferAlerts;
             set
             {
                 if (this._enableFailedTransferAlerts == value)
@@ -66,7 +60,7 @@ namespace SyncTrayzor.Services
         private bool _enableConflictedFileAlerts;
         public bool EnableConflictedFileAlerts
         {
-            get { return this._enableConflictedFileAlerts; }
+            get => this._enableConflictedFileAlerts;
             set
             {
                 if (this._enableConflictedFileAlerts == value)

+ 1 - 1
src/SyncTrayzor/Services/ApplicationState.cs

@@ -36,7 +36,7 @@ namespace SyncTrayzor.Services
 
         public ShutdownMode ShutdownMode
         {
-            get { return this.application.ShutdownMode; }
+            get => this.application.ShutdownMode;
             set
             {
                 // This will fail if we're shutting down

+ 2 - 4
src/SyncTrayzor/Services/AutostartProvider.cs

@@ -126,8 +126,7 @@ namespace SyncTrayzor.Services
                             numbersSeen.Add(Int32.Parse(numberValue));
 
                         // See if this one points to our application
-                        var keyValue = key.GetValue(entry) as string;
-                        if (keyValue != null && keyValue.StartsWith($"\"{this.assemblyProvider.Location}\""))
+                        if (key.GetValue(entry) is string keyValue && keyValue.StartsWith($"\"{this.assemblyProvider.Location}\""))
                         {
                             foundKey = entry;
                             break;
@@ -172,8 +171,7 @@ namespace SyncTrayzor.Services
 
             using (var registryKey = this.OpenRegistryKey(false))
             {
-                var value = registryKey.GetValue(this.keyName) as string;
-                if (value != null)
+                if (registryKey.GetValue(this.keyName) is string value)
                 {
                     autoStart = true;
                     if (value.Contains(" -minimized"))

+ 4 - 4
src/SyncTrayzor/Services/Config/Configuration.cs

@@ -15,7 +15,7 @@ namespace SyncTrayzor.Services.Config
         [XmlAttribute("Version")]
         public int Version
         {
-            get { return CurrentVersion; }
+            get => CurrentVersion;
             set
             {
                 if (CurrentVersion != value)
@@ -50,8 +50,8 @@ namespace SyncTrayzor.Services.Config
         [XmlElement("LatestNotifiedVersion")]
         public string LatestNotifiedVersionRaw
         {
-            get { return this.LatestNotifiedVersion == null ? null : this.LatestNotifiedVersion.ToString(); }
-            set { this.LatestNotifiedVersion = value == null ? null : new Version(value); }
+            get => this.LatestNotifiedVersion?.ToString();
+            set => this.LatestNotifiedVersion = value == null ? null : new Version(value);
         }
 
         public bool UseComputerCulture { get; set; }
@@ -97,7 +97,7 @@ namespace SyncTrayzor.Services.Config
             this.ObfuscateDeviceIDs = true;
             this.LatestNotifiedVersion = null;
             this.UseComputerCulture = true;
-            this.SyncthingConsoleHeight = Configuration.DefaultSyncthingConsoleHeight;
+            this.SyncthingConsoleHeight = DefaultSyncthingConsoleHeight;
             this.WindowPlacement = null;
             this.SyncthingWebBrowserZoomLevel = 0;
             this.LastSeenInstallCount = 0;

+ 2 - 7
src/SyncTrayzor/Services/Config/ConfigurationProvider.cs

@@ -13,11 +13,7 @@ namespace SyncTrayzor.Services.Config
     public class ConfigurationChangedEventArgs : EventArgs
     {
         private readonly Configuration baseConfiguration;
-        public Configuration NewConfiguration
-        {
-            // Ensure we always clone it, so people can modify
-            get { return new Configuration(this.baseConfiguration); }
-        }
+        public Configuration NewConfiguration => new Configuration(this.baseConfiguration);
 
         public ConfigurationChangedEventArgs(Configuration newConfiguration)
         {
@@ -93,8 +89,7 @@ namespace SyncTrayzor.Services.Config
             if (!this.filesystem.DirectoryExists(Path.GetDirectoryName(this.paths.ConfigurationFilePath)))
                 this.filesystem.CreateDirectory(Path.GetDirectoryName(this.paths.ConfigurationFilePath));
 
-            bool hadToCreateConfiguration;
-            this.currentConfig = this.LoadFromDisk(defaultConfiguration, out hadToCreateConfiguration);
+            this.currentConfig = this.LoadFromDisk(defaultConfiguration, out bool hadToCreateConfiguration);
             this.HadToCreateConfiguration = hadToCreateConfiguration;
 
             bool updateConfigInstallCount = false;

+ 1 - 7
src/SyncTrayzor/Services/Config/IconAnimationMode.cs

@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SyncTrayzor.Services.Config
+namespace SyncTrayzor.Services.Config
 {
     public enum IconAnimationMode
     {

+ 0 - 1
src/SyncTrayzor/Services/ConfigurationApplicator.cs

@@ -3,7 +3,6 @@ using SyncTrayzor.Services.Config;
 using SyncTrayzor.Services.Conflicts;
 using SyncTrayzor.Services.UpdateManagement;
 using SyncTrayzor.Syncthing;
-using SyncTrayzor.Utils;
 using System;
 using System.Linq;
 using SyncTrayzor.Services.Metering;

+ 2 - 4
src/SyncTrayzor/Services/Conflicts/ConflictFileManager.cs

@@ -166,13 +166,11 @@ namespace SyncTrayzor.Services.Conflicts
                         if (this.IsFileIgnored(filePath))
                             continue;
 
-                        ParsedConflictFileInfo conflictFileInfo;
                         // We may not be able to parse it properly (conflictPattern is pretty basic), or it might not exist, or...
-                        if (!this.TryFindBaseFileForConflictFile(filePath, out conflictFileInfo))
+                        if (!this.TryFindBaseFileForConflictFile(filePath, out var conflictFileInfo))
                             continue;
 
-                        List<ParsedConflictFileInfo> existingConflicts;
-                        if (!conflictLookup.TryGetValue(conflictFileInfo.OriginalPath, out existingConflicts))
+                        if (!conflictLookup.TryGetValue(conflictFileInfo.OriginalPath, out var existingConflicts))
                         {
                             existingConflicts = new List<ParsedConflictFileInfo>();
                             conflictLookup.Add(conflictFileInfo.OriginalPath, existingConflicts);

+ 2 - 3
src/SyncTrayzor/Services/Conflicts/ConflictFileWatcher.cs

@@ -66,7 +66,7 @@ namespace SyncTrayzor.Services.Conflicts
         private bool _isEnabled;
         public bool IsEnabled
         {
-            get { return this._isEnabled; }
+            get => this._isEnabled;
             set
             {
                 if (this._isEnabled == value)
@@ -154,8 +154,7 @@ namespace SyncTrayzor.Services.Conflicts
             {
                 foreach (var conflictedFile in this.conflictFileOptions)
                 {
-                    ParsedConflictFileInfo parsedConflictFileInfo;
-                    if (this.conflictFileManager.TryFindBaseFileForConflictFile(conflictedFile, out parsedConflictFileInfo))
+                    if (this.conflictFileManager.TryFindBaseFileForConflictFile(conflictedFile, out var parsedConflictFileInfo))
                     {
                         conflictFiles.Add(parsedConflictFileInfo.OriginalPath);
                     }

+ 0 - 4
src/SyncTrayzor/Services/DonationManager.cs

@@ -1,9 +1,5 @@
 using System;
-using System.Collections.Generic;
 using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using Stylet;
 using SyncTrayzor.Services.Config;
 

+ 1 - 3
src/SyncTrayzor/Services/FileWatcher.cs

@@ -255,9 +255,7 @@ namespace SyncTrayzor.Services
 
         public virtual void OnPathChanged(string path, bool pathExists)
         {
-            var handler = this.PathChanged;
-            if (handler != null)
-                handler(this, new PathChangedEventArgs(this.Directory, path, pathExists));
+            this.PathChanged?.Invoke(this, new PathChangedEventArgs(this.Directory, path, pathExists));
         }
 
         private string GetLongPathName(string path)

+ 0 - 4
src/SyncTrayzor/Services/Ipc/IpcCommsClientFactory.cs

@@ -1,10 +1,6 @@
 using NLog;
 using System;
-using System.Collections.Generic;
 using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace SyncTrayzor.Services.Ipc
 {

+ 2 - 2
src/SyncTrayzor/Services/MemoryUsageLogger.cs

@@ -16,8 +16,8 @@ namespace SyncTrayzor.Services
 
         public bool Enabled
         {
-            get { return this.timer.Enabled; }
-            set { this.timer.Enabled = value; }
+            get => this.timer.Enabled;
+            set => this.timer.Enabled = value;
         }
 
         public MemoryUsageLogger()

+ 3 - 5
src/SyncTrayzor/Services/Metering/MeteredNetworkManager.cs

@@ -37,7 +37,7 @@ namespace SyncTrayzor.Services.Metering
         private bool _isEnabled;
         public bool IsEnabled
         {
-            get { return this._isEnabled; }
+            get => this._isEnabled;
             set
             {
                 if (this._isEnabled == value)
@@ -115,8 +115,7 @@ namespace SyncTrayzor.Services.Metering
             bool changed = false;
             lock (this.syncRoot)
             {
-                DeviceState deviceState;
-                if (!this.deviceStates.TryGetValue(e.Device, out deviceState))
+                if (!this.deviceStates.TryGetValue(e.Device, out var deviceState))
                 {
                     logger.Warn($"Unable to pause device {e.Device.DeviceId} as we don't have a record of its state. This should not happen");
                     return;
@@ -147,8 +146,7 @@ namespace SyncTrayzor.Services.Metering
             bool changed = false;
             lock (this.syncRoot)
             {
-                DeviceState deviceState;
-                if (!this.deviceStates.TryGetValue(e.Device, out deviceState))
+                if (!this.deviceStates.TryGetValue(e.Device, out var deviceState))
                 {
                     logger.Warn($"Unable to resume device {e.Device.DeviceId} as we don't have a record of its state. This should not happen");
                     return;

+ 1 - 2
src/SyncTrayzor/Services/Metering/NetworkCostManager.cs

@@ -66,8 +66,7 @@ namespace SyncTrayzor.Services.Metering
 
             try
             {
-                uint costVal;
-                this.networkListManager.GetCost(out costVal, ref sockAddr);
+                this.networkListManager.GetCost(out uint costVal, ref sockAddr);
                 var cost = (NLM_CONNECTION_COST)costVal;
                 return !cost.HasFlag(NLM_CONNECTION_COST.NLM_CONNECTION_COST_UNRESTRICTED);
             }

+ 1 - 2
src/SyncTrayzor/Services/UpdateManagement/UpdateDownloader.cs

@@ -39,8 +39,7 @@ namespace SyncTrayzor.Services.UpdateManagement
 
             var sha512sumOutcome = await this.DownloadAndVerifyFileAsync<Stream>(sha512sumUrl, version, sha512sumDownloadPath, false, () =>
                 {
-                    Stream sha512sumContents;
-                    var passed = this.installerVerifier.VerifySha512sum(sha512sumDownloadPath, out sha512sumContents);
+                    var passed = this.installerVerifier.VerifySha512sum(sha512sumDownloadPath, out Stream sha512sumContents);
                     return Tuple.Create(passed, sha512sumContents);
                 });
 

+ 3 - 2
src/SyncTrayzor/Services/UpdateManagement/UpdateManager.cs

@@ -66,7 +66,7 @@ namespace SyncTrayzor.Services.UpdateManagement
         private bool _checkForUpdates;
         public bool CheckForUpdates
         {
-            get { return this._checkForUpdates; }
+            get => this._checkForUpdates;
             set
             {
                 if (this._checkForUpdates == value)
@@ -246,7 +246,7 @@ namespace SyncTrayzor.Services.UpdateManagement
                     case VersionPromptResult.InstallNow:
                         Debug.Assert(variantHandler.CanAutoInstall);
                         logger.Info("Auto-installing {0}", checkResult.NewVersion);
-                        variantHandler. AutoInstall(this.PathToRestartApplication());
+                        variantHandler.AutoInstall(this.PathToRestartApplication());
                         break;
 
                     case VersionPromptResult.Download:
@@ -264,6 +264,7 @@ namespace SyncTrayzor.Services.UpdateManagement
                         logger.Info("Not installing version {0}, but will remind later", checkResult.NewVersion);
                         break;
 
+                    case VersionPromptResult.ShowMoreDetails:
                     default:
                         Debug.Assert(false);
                         break;

+ 2 - 2
src/SyncTrayzor/Services/UpdateManagement/UpdateNotificationResponse.cs

@@ -10,8 +10,8 @@ namespace SyncTrayzor.Services.UpdateManagement
 
         public Version Version
         {
-            get { return String.IsNullOrWhiteSpace(this.VersionRaw) ? null : new Version(this.VersionRaw); }
-            set { this.VersionRaw = value.ToString(3); }
+            get => String.IsNullOrWhiteSpace(this.VersionRaw) ? null : new Version(this.VersionRaw);
+            set => this.VersionRaw = value.ToString(3);
         }
 
         [JsonProperty("direct_download_url")]

+ 1 - 2
src/SyncTrayzor/Services/UserActivityMonitor.cs

@@ -32,8 +32,7 @@ namespace SyncTrayzor.Services
                 //Check we haven't picked up the desktop or the shell
                 if (!(hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle)))
                 {
-                    RECT appBounds;
-                    NativeMethods.GetWindowRect(hWnd, out appBounds);
+                    NativeMethods.GetWindowRect(hWnd, out RECT appBounds);
                     //determine if window is fullscreen
                     // TODO: Not sure if there's a nice non-winforms way of doing this
                     var screenBounds = Screen.FromHandle(hWnd).Bounds;

+ 2 - 2
src/SyncTrayzor/Services/WatchedFolderMonitor.cs

@@ -27,13 +27,13 @@ namespace SyncTrayzor.Services
         private List<string> _watchedFolders;
         public IEnumerable<string> WatchedFolderIDs
         {
-            get { return this._watchedFolders; }
+            get => this._watchedFolders;
             set
             {
                 if (this._watchedFolders != null && value != null && this._watchedFolders.SequenceEqual(value))
                     return;
 
-                this._watchedFolders = value != null ? value.ToList() : null;
+                this._watchedFolders = value?.ToList();
                 this.Reset();
             }
         }

+ 106 - 69
src/SyncTrayzor/SyncTrayzor.ruleset

@@ -1,70 +1,107 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RuleSet Name="Rules for SyncTrayzor" Description="Code analysis rules for SyncTrayzor.csproj." ToolsVersion="14.0">
-  <Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
-    <Rule Id="CA1001" Action="Warning" />
-    <Rule Id="CA1009" Action="Warning" />
-    <Rule Id="CA1016" Action="Warning" />
-    <Rule Id="CA1033" Action="Warning" />
-    <Rule Id="CA1049" Action="Warning" />
-    <Rule Id="CA1060" Action="Warning" />
-    <Rule Id="CA1061" Action="Warning" />
-    <Rule Id="CA1063" Action="Warning" />
-    <Rule Id="CA1065" Action="Warning" />
-    <Rule Id="CA1301" Action="Warning" />
-    <Rule Id="CA1400" Action="Warning" />
-    <Rule Id="CA1401" Action="Warning" />
-    <Rule Id="CA1403" Action="Warning" />
-    <Rule Id="CA1404" Action="Warning" />
-    <Rule Id="CA1405" Action="Warning" />
-    <Rule Id="CA1410" Action="Warning" />
-    <Rule Id="CA1415" Action="Warning" />
-    <Rule Id="CA1821" Action="Warning" />
-    <Rule Id="CA1900" Action="Warning" />
-    <Rule Id="CA1901" Action="Warning" />
-    <Rule Id="CA2002" Action="Warning" />
-    <Rule Id="CA2100" Action="Warning" />
-    <Rule Id="CA2101" Action="Warning" />
-    <Rule Id="CA2108" Action="Warning" />
-    <Rule Id="CA2111" Action="Warning" />
-    <Rule Id="CA2112" Action="Warning" />
-    <Rule Id="CA2114" Action="Warning" />
-    <Rule Id="CA2116" Action="Warning" />
-    <Rule Id="CA2117" Action="Warning" />
-    <Rule Id="CA2122" Action="Warning" />
-    <Rule Id="CA2123" Action="Warning" />
-    <Rule Id="CA2124" Action="Warning" />
-    <Rule Id="CA2126" Action="Warning" />
-    <Rule Id="CA2131" Action="Warning" />
-    <Rule Id="CA2132" Action="Warning" />
-    <Rule Id="CA2133" Action="Warning" />
-    <Rule Id="CA2134" Action="Warning" />
-    <Rule Id="CA2137" Action="Warning" />
-    <Rule Id="CA2138" Action="Warning" />
-    <Rule Id="CA2140" Action="Warning" />
-    <Rule Id="CA2141" Action="Warning" />
-    <Rule Id="CA2146" Action="Warning" />
-    <Rule Id="CA2147" Action="Warning" />
-    <Rule Id="CA2149" Action="Warning" />
-    <Rule Id="CA2200" Action="Warning" />
-    <Rule Id="CA2202" Action="Warning" />
-    <Rule Id="CA2207" Action="Warning" />
-    <Rule Id="CA2212" Action="Warning" />
-    <Rule Id="CA2213" Action="Warning" />
-    <Rule Id="CA2214" Action="Warning" />
-    <Rule Id="CA2216" Action="Warning" />
-    <Rule Id="CA2220" Action="Warning" />
-    <Rule Id="CA2229" Action="Warning" />
-    <Rule Id="CA2231" Action="Warning" />
-    <Rule Id="CA2232" Action="Warning" />
-    <Rule Id="CA2235" Action="Warning" />
-    <Rule Id="CA2236" Action="Warning" />
-    <Rule Id="CA2237" Action="Warning" />
-    <Rule Id="CA2238" Action="Warning" />
-    <Rule Id="CA2240" Action="Warning" />
-    <Rule Id="CA2241" Action="Warning" />
-    <Rule Id="CA2242" Action="Warning" />
-  </Rules>
-  <Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp.Features" RuleNamespace="Microsoft.CodeAnalysis.CSharp.Features">
-    <Rule Id="IDE0003" Action="None" />
-  </Rules>
+<?xml version="1.0" encoding="utf-8"?>
+<RuleSet Name="Rules for SyncTrayzor" Description="Code analysis rules for SyncTrayzor.csproj." ToolsVersion="15.0">
+  <Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
+    <Rule Id="CA1001" Action="Warning" />
+    <Rule Id="CA1009" Action="Warning" />
+    <Rule Id="CA1016" Action="Warning" />
+    <Rule Id="CA1033" Action="Warning" />
+    <Rule Id="CA1049" Action="Warning" />
+    <Rule Id="CA1060" Action="Warning" />
+    <Rule Id="CA1061" Action="Warning" />
+    <Rule Id="CA1063" Action="Warning" />
+    <Rule Id="CA1065" Action="Warning" />
+    <Rule Id="CA1301" Action="Warning" />
+    <Rule Id="CA1400" Action="Warning" />
+    <Rule Id="CA1401" Action="Warning" />
+    <Rule Id="CA1403" Action="Warning" />
+    <Rule Id="CA1404" Action="Warning" />
+    <Rule Id="CA1405" Action="Warning" />
+    <Rule Id="CA1410" Action="Warning" />
+    <Rule Id="CA1415" Action="Warning" />
+    <Rule Id="CA1821" Action="Warning" />
+    <Rule Id="CA1900" Action="Warning" />
+    <Rule Id="CA1901" Action="Warning" />
+    <Rule Id="CA2002" Action="Warning" />
+    <Rule Id="CA2100" Action="Warning" />
+    <Rule Id="CA2101" Action="Warning" />
+    <Rule Id="CA2108" Action="Warning" />
+    <Rule Id="CA2111" Action="Warning" />
+    <Rule Id="CA2112" Action="Warning" />
+    <Rule Id="CA2114" Action="Warning" />
+    <Rule Id="CA2116" Action="Warning" />
+    <Rule Id="CA2117" Action="Warning" />
+    <Rule Id="CA2122" Action="Warning" />
+    <Rule Id="CA2123" Action="Warning" />
+    <Rule Id="CA2124" Action="Warning" />
+    <Rule Id="CA2126" Action="Warning" />
+    <Rule Id="CA2131" Action="Warning" />
+    <Rule Id="CA2132" Action="Warning" />
+    <Rule Id="CA2133" Action="Warning" />
+    <Rule Id="CA2134" Action="Warning" />
+    <Rule Id="CA2137" Action="Warning" />
+    <Rule Id="CA2138" Action="Warning" />
+    <Rule Id="CA2140" Action="Warning" />
+    <Rule Id="CA2141" Action="Warning" />
+    <Rule Id="CA2146" Action="Warning" />
+    <Rule Id="CA2147" Action="Warning" />
+    <Rule Id="CA2149" Action="Warning" />
+    <Rule Id="CA2200" Action="Warning" />
+    <Rule Id="CA2202" Action="Warning" />
+    <Rule Id="CA2207" Action="Warning" />
+    <Rule Id="CA2212" Action="Warning" />
+    <Rule Id="CA2213" Action="Warning" />
+    <Rule Id="CA2214" Action="Warning" />
+    <Rule Id="CA2216" Action="Warning" />
+    <Rule Id="CA2220" Action="Warning" />
+    <Rule Id="CA2229" Action="Warning" />
+    <Rule Id="CA2231" Action="Warning" />
+    <Rule Id="CA2232" Action="Warning" />
+    <Rule Id="CA2235" Action="Warning" />
+    <Rule Id="CA2236" Action="Warning" />
+    <Rule Id="CA2237" Action="Warning" />
+    <Rule Id="CA2238" Action="Warning" />
+    <Rule Id="CA2240" Action="Warning" />
+    <Rule Id="CA2241" Action="Warning" />
+    <Rule Id="CA2242" Action="Warning" />
+  </Rules>
+  <Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp.EditorFeatures" RuleNamespace="Microsoft.CodeAnalysis.CSharp.EditorFeatures">
+    <Rule Id="IDE0032" Action="Info" />
+  </Rules>
+  <Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp.Features" RuleNamespace="Microsoft.CodeAnalysis.CSharp.Features">
+    <Rule Id="IDE0001" Action="Info" />
+    <Rule Id="IDE0002" Action="None" />
+    <Rule Id="IDE0003" Action="None" />
+    <Rule Id="IDE0004" Action="Info" />
+    <Rule Id="IDE0005" Action="Info" />
+    <Rule Id="IDE0007" Action="Info" />
+    <Rule Id="IDE0008" Action="Info" />
+    <Rule Id="IDE0009" Action="Info" />
+    <Rule Id="IDE0011" Action="None" />
+    <Rule Id="IDE0012" Action="Info" />
+    <Rule Id="IDE0013" Action="Info" />
+    <Rule Id="IDE0014" Action="Info" />
+    <Rule Id="IDE0015" Action="Info" />
+    <Rule Id="IDE0016" Action="Info" />
+    <Rule Id="IDE0017" Action="Info" />
+    <Rule Id="IDE0018" Action="Info" />
+    <Rule Id="IDE0019" Action="Info" />
+    <Rule Id="IDE0020" Action="Info" />
+    <Rule Id="IDE0021" Action="Info" />
+    <Rule Id="IDE0022" Action="None" />
+    <Rule Id="IDE0023" Action="Info" />
+    <Rule Id="IDE0024" Action="Info" />
+    <Rule Id="IDE0025" Action="Info" />
+    <Rule Id="IDE0026" Action="Info" />
+    <Rule Id="IDE0027" Action="Info" />
+    <Rule Id="IDE0028" Action="Info" />
+    <Rule Id="IDE0029" Action="Info" />
+    <Rule Id="IDE0030" Action="Info" />
+    <Rule Id="IDE0031" Action="Info" />
+    <Rule Id="IDE1005" Action="Info" />
+    <Rule Id="IDE1006" Action="None" />
+  </Rules>
+  <Rules AnalyzerId="Microsoft.CodeAnalysis.Features" RuleNamespace="Microsoft.CodeAnalysis.Features">
+    <Rule Id="IDE0010" Action="Info" />
+    <Rule Id="IDE0033" Action="Info" />
+  </Rules>
 </RuleSet>

+ 2 - 2
src/SyncTrayzor/Syncthing/ApiClient/Config.cs

@@ -44,8 +44,8 @@ namespace SyncTrayzor.Syncthing.ApiClient
 
         public TimeSpan RescanInterval
         {
-            get { return TimeSpan.FromSeconds(this.RescanIntervalSeconds); }
-            set { this.RescanIntervalSeconds = (long)value.TotalSeconds; }
+            get => TimeSpan.FromSeconds(this.RescanIntervalSeconds);
+            set => this.RescanIntervalSeconds = (long)value.TotalSeconds;
         }
 
         [JsonProperty("invalid")]

+ 1 - 2
src/SyncTrayzor/Syncthing/ApiClient/DeviceConnectedEvent.cs

@@ -1,5 +1,4 @@
-using System;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
 
 namespace SyncTrayzor.Syncthing.ApiClient
 {

+ 1 - 2
src/SyncTrayzor/Syncthing/ApiClient/EventConverter.cs

@@ -44,8 +44,7 @@ namespace SyncTrayzor.Syncthing.ApiClient
             if (eventType == EventType.Unknown)
                 logger.Warn($"Unknown event type: {jObject["type"]}");
 
-            Type type;
-            if (eventTypes.TryGetValue(eventType, out type))
+            if (eventTypes.TryGetValue(eventType, out Type type))
                 return (Event)jObject.ToObject(type);
             else
                 return jObject.ToObject<GenericEvent>();

+ 1 - 2
src/SyncTrayzor/Syncthing/ApiClient/StartupCompleteEvent.cs

@@ -1,5 +1,4 @@
-using System;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
 
 namespace SyncTrayzor.Syncthing.ApiClient
 {

+ 2 - 2
src/SyncTrayzor/Syncthing/ApiClient/StateChangedEvent.cs

@@ -19,8 +19,8 @@ namespace SyncTrayzor.Syncthing.ApiClient
 
         public TimeSpan Duration
         {
-            get { return TimeSpan.FromSeconds(this.DurationSeconds); }
-            set { this.DurationSeconds = value.TotalSeconds; }
+            get => TimeSpan.FromSeconds(this.DurationSeconds);
+            set => this.DurationSeconds = value.TotalSeconds;
         }
     }
 

+ 0 - 1
src/SyncTrayzor/Syncthing/ApiClient/SyncthingHttpClientHandler.cs

@@ -2,7 +2,6 @@
 using System.Net.Http;
 using System.Threading;
 using System.Threading.Tasks;
-using System;
 
 namespace SyncTrayzor.Syncthing.ApiClient
 {

+ 2 - 2
src/SyncTrayzor/Syncthing/Devices/Device.cs

@@ -57,9 +57,9 @@ namespace SyncTrayzor.Syncthing.Devices
 
         public bool Equals(Device other)
         {
-            if (Object.ReferenceEquals(this, other))
+            if (ReferenceEquals(this, other))
                 return true;
-            if (Object.ReferenceEquals(other, null))
+            if (ReferenceEquals(other, null))
                 return false;
 
             return this.DeviceId == other.DeviceId;

+ 3 - 6
src/SyncTrayzor/Syncthing/Devices/SyncthingAddressParser.cs

@@ -16,12 +16,10 @@ namespace SyncTrayzor.Syncthing.Devices
             // Therefore do some mapping...
 
             // Use a URI to parse off the port
-            Uri uri;
-            if (!Uri.TryCreate($"tcp://{input}", UriKind.Absolute, out uri))
+            if (!Uri.TryCreate($"tcp://{input}", UriKind.Absolute, out Uri uri))
                 throw new FormatException($"Unable to parse input '{input}' into a URI");
 
-            IPAddress ipWithoutScope;
-            if (!IPAddress.TryParse(uri.Host, out ipWithoutScope))
+            if (!IPAddress.TryParse(uri.Host, out IPAddress ipWithoutScope))
                 throw new FormatException($"Unable to parse URI host {uri.Host} into an IPAddress");
 
             IPAddress ipWithScope;
@@ -46,8 +44,7 @@ namespace SyncTrayzor.Syncthing.Devices
                 var scopeName = hostWithScopeParts[1];
 
                 // Just in case Syncthing ever starts returning proper scope IDs...
-                long scopeId;
-                if (!Int64.TryParse(scopeName, out scopeId))
+                if (!Int64.TryParse(scopeName, out long scopeId))
                 {
 
                     var scopeLevel = ipWithoutScope.IsIPv6SiteLocal ? ScopeLevel.Site : ScopeLevel.Interface;

+ 9 - 22
src/SyncTrayzor/Syncthing/Devices/SyncthingDeviceManager.cs

@@ -49,17 +49,10 @@ namespace SyncTrayzor.Syncthing.Devices
 
         public SyncthingDeviceManager(SynchronizedTransientWrapper<ISyncthingApiClient> apiClient, ISyncthingEventWatcher eventWatcher, ISyncthingCapabilities capabilities)
         {
-            if (apiClient == null)
-                throw new ArgumentNullException(nameof(apiClient));
-            if (eventWatcher == null)
-                throw new ArgumentNullException(nameof(eventWatcher));
-            if (capabilities == null)
-                throw new ArgumentNullException(nameof(capabilities));
-
             this.eventDispatcher = new SynchronizedEventDispatcher(this);
-            this.apiClient = apiClient;
-            this.eventWatcher = eventWatcher;
-            this.capabilities = capabilities;
+            this.apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
+            this.eventWatcher = eventWatcher ?? throw new ArgumentNullException(nameof(eventWatcher));
+            this.capabilities = capabilities ?? throw new ArgumentNullException(nameof(capabilities));
 
             this.eventWatcher.DeviceConnected += this.EventDeviceConnected;
             this.eventWatcher.DeviceDisconnected += this.EventDeviceDisconnected;
@@ -93,8 +86,7 @@ namespace SyncTrayzor.Syncthing.Devices
 
             foreach (var device in devices)
             {
-                Device existingDevice;
-                if (this.devices.TryGetValue(device.DeviceId, out existingDevice))
+                if (this.devices.TryGetValue(device.DeviceId, out var existingDevice))
                 {
                     if (!existingDevice.IsConnected && device.IsConnected)
                         changeNotifications.Add(() => this.OnDeviceConnected(device));
@@ -119,8 +111,7 @@ namespace SyncTrayzor.Syncthing.Devices
             var devices = config.Devices.DistinctBy(x => x.DeviceID).Select(device =>
             {
                 var deviceObj = new Device(device.DeviceID, device.Name);
-                ItemConnectionData connectionData;
-                if (connections.DeviceConnections.TryGetValue(device.DeviceID, out connectionData))
+                if (connections.DeviceConnections.TryGetValue(device.DeviceID, out var connectionData))
                 {
                     if (connectionData.Connected && connectionData.Address != null)
                         deviceObj.SetConnected(SyncthingAddressParser.Parse(connectionData.Address));
@@ -163,8 +154,7 @@ namespace SyncTrayzor.Syncthing.Devices
 
         private void EventDeviceConnected(object sender, EventWatcher.DeviceConnectedEventArgs e)
         {
-            Device device;
-            if (!this.devices.TryGetValue(e.DeviceId, out device))
+            if (!this.devices.TryGetValue(e.DeviceId, out var device))
             {
                 logger.Warn("Unexpected device connected: {0}, address {1}. It wasn't fetched when we fetched our config", e.DeviceId, e.Address);
                 return; // Not expecting this device! It wasn't in the config...
@@ -177,8 +167,7 @@ namespace SyncTrayzor.Syncthing.Devices
 
         private void EventDeviceDisconnected(object sender, EventWatcher.DeviceDisconnectedEventArgs e)
         {
-            Device device;
-            if (!this.devices.TryGetValue(e.DeviceId, out device))
+            if (!this.devices.TryGetValue(e.DeviceId, out var device))
             {
                 logger.Warn("Unexpected device connected: {0}, error {1}. It wasn't fetched when we fetched our config", e.DeviceId, e.Error);
                 return; // Not expecting this device! It wasn't in the config...
@@ -191,8 +180,7 @@ namespace SyncTrayzor.Syncthing.Devices
 
         private void EventDevicePaused(object sender, EventWatcher.DevicePausedEventArgs e)
         {
-            Device device;
-            if (!this.devices.TryGetValue(e.DeviceId, out device))
+            if (!this.devices.TryGetValue(e.DeviceId, out var device))
             {
                 logger.Warn("Unexpected device paused: {0}. It wasn't fetched when we fetched our config", e.DeviceId);
                 return; // Not expecting this device! It wasn't in the config...
@@ -205,8 +193,7 @@ namespace SyncTrayzor.Syncthing.Devices
 
         private void EventDeviceResumed(object sender, EventWatcher.DeviceResumedEventArgs e)
         {
-            Device device;
-            if (!this.devices.TryGetValue(e.DeviceId, out device))
+            if (!this.devices.TryGetValue(e.DeviceId, out var device))
             {
                 logger.Warn("Unexpected device resumed: {0}. It wasn't fetched when we fetched our config", e.DeviceId);
                 return; // Not expecting this device! It wasn't in the config...

+ 2 - 2
src/SyncTrayzor/Syncthing/Folders/FolderError.cs

@@ -15,9 +15,9 @@ namespace SyncTrayzor.Syncthing.Folders
 
         public bool Equals(FolderError other)
         {
-            if (Object.ReferenceEquals(this, other))
+            if (ReferenceEquals(this, other))
                 return true;
-            if (Object.ReferenceEquals(other, null))
+            if (ReferenceEquals(other, null))
                 return false;
 
             return this.Error == other.Error &&

+ 1 - 2
src/SyncTrayzor/Syncthing/Folders/FolderStateTransformer.cs

@@ -17,8 +17,7 @@ namespace SyncTrayzor.Syncthing.Folders
 
         public static FolderSyncState SyncStateFromString(string state)
         {
-            FolderSyncState syncState;
-            if (folderSyncStateLookup.TryGetValue(state, out syncState))
+            if (folderSyncStateLookup.TryGetValue(state, out var syncState))
                 return syncState;
 
             logger.Warn($"Unknown folder sync state {state}. Defaulting to Idle");

+ 6 - 14
src/SyncTrayzor/Syncthing/Folders/SyncthingFolderManager.cs

@@ -1,5 +1,4 @@
 using NLog;
-using RestEase;
 using SyncTrayzor.Syncthing.ApiClient;
 using SyncTrayzor.Syncthing.EventWatcher;
 using SyncTrayzor.Utils;
@@ -8,7 +7,6 @@ using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
-using System.Net;
 using System.Threading;
 using System.Threading.Tasks;
 
@@ -113,8 +111,7 @@ namespace SyncTrayzor.Syncthing.Folders
             // Re-use the existing folder object if possible
             foreach (var folder in folders)
             {
-                Folder existingFolder;
-                if (existingFolders.TryGetValue(folder.FolderId, out existingFolder))
+                if (existingFolders.TryGetValue(folder.FolderId, out var existingFolder))
                 {
                     if (existingFolder.SyncState != folder.SyncState)
                     {
@@ -179,8 +176,7 @@ namespace SyncTrayzor.Syncthing.Folders
 
         private void ItemStarted(string folderId, string item)
         {
-            Folder folder;
-            if (!this.folders.TryGetValue(folderId, out folder))
+            if (!this.folders.TryGetValue(folderId, out var folder))
                 return; // Don't know about it
 
             folder.AddSyncingPath(item);
@@ -188,8 +184,7 @@ namespace SyncTrayzor.Syncthing.Folders
 
         private void ItemFinished(string folderId, string item)
         {
-            Folder folder;
-            if (!this.folders.TryGetValue(folderId, out folder))
+            if (!this.folders.TryGetValue(folderId, out var folder))
                 return; // Don't know about it
 
             folder.RemoveSyncingPath(item);
@@ -197,8 +192,7 @@ namespace SyncTrayzor.Syncthing.Folders
 
         private void FolderErrorsChangedEvt(string folderId, List<FolderErrorData> errors)
         {
-            Folder folder;
-            if (!this.folders.TryGetValue(folderId, out folder))
+            if (!this.folders.TryGetValue(folderId, out var folder))
                 return; // Don't know about it
 
             var folderErrors = errors.Select(x => new FolderError(x.Error, x.Path)).ToList();
@@ -208,8 +202,7 @@ namespace SyncTrayzor.Syncthing.Folders
 
         private void FolderSyncStateChanged(SyncStateChangedEventArgs e)
         {
-            Folder folder;
-            if (!this.folders.TryGetValue(e.FolderId, out folder))
+            if (!this.folders.TryGetValue(e.FolderId, out var folder))
                 return; // We don't know about this folder
 
             var syncState = FolderStateTransformer.SyncStateFromString(e.SyncState);
@@ -226,8 +219,7 @@ namespace SyncTrayzor.Syncthing.Folders
 
         private void FolderStatusChanged(string folderId, FolderStatus folderStatus)
         {
-            Folder folder;
-            if (!this.folders.TryGetValue(folderId, out folder))
+            if (!this.folders.TryGetValue(folderId, out var folder))
                 return; // Don't know about it
 
             folder.Status = folderStatus;

+ 6 - 6
src/SyncTrayzor/Syncthing/SyncthingManager.cs

@@ -396,8 +396,10 @@ namespace SyncTrayzor.Syncthing
             // Things will attempt to talk to Syncthing over http. If Syncthing is set to 'https only', this will redirect.
             var preferredAddressWithScheme = new Uri("https://" + this.PreferredHostAndPort);
             var port = this.freePortFinder.FindFreePort(preferredAddressWithScheme.Port);
-            var uriBuilder = new UriBuilder(preferredAddressWithScheme);
-            uriBuilder.Port = port;
+            var uriBuilder = new UriBuilder(preferredAddressWithScheme)
+            {
+                Port = port
+            };
             this.Address = uriBuilder.Uri;
 
             this.processRunner.ApiKey = this.ApiKey;
@@ -544,12 +546,10 @@ namespace SyncTrayzor.Syncthing
 
         private void OnFolderRejected(string deviceId, string folderId)
         {
-            Device device;
-            if (!this.Devices.TryFetchById(deviceId, out device))
+            if (!this.Devices.TryFetchById(deviceId, out var device))
                 return;
 
-            Folder folder;
-            if (!this.Folders.TryFetchById(folderId, out folder))
+            if (!this.Folders.TryFetchById(folderId, out var folder))
                 return;
 
             this.eventDispatcher.Raise(this.FolderRejected, new FolderRejectedEventArgs(device, folder));

+ 2 - 2
src/SyncTrayzor/Syncthing/TransferHistory/FailingTransfer.cs

@@ -22,9 +22,9 @@ namespace SyncTrayzor.Syncthing.TransferHistory
 
         public bool Equals(FailingTransfer other)
         {
-            if (Object.ReferenceEquals(other, null))
+            if (ReferenceEquals(other, null))
                 return false;
-            if (Object.ReferenceEquals(this, other))
+            if (ReferenceEquals(this, other))
                 return true;
 
             return this.FolderId == other.FolderId && this.Path == other.Path;

+ 3 - 6
src/SyncTrayzor/Syncthing/TransferHistory/SyncthingTransferHistory.cs

@@ -171,8 +171,7 @@ namespace SyncTrayzor.Syncthing.TransferHistory
                 }
                 else
                 {
-                    FailingTransfer failingTransfer;
-                    if (!this.currentlyFailingTransfers.TryGetValue(key, out failingTransfer) || failingTransfer.Error != error)
+                    if (!this.currentlyFailingTransfers.TryGetValue(key, out var failingTransfer) || failingTransfer.Error != error)
                     {
                         // Remove will only do something in the case that the failure existed, but the error changed
                         this.currentlyFailingTransfers.Remove(key);
@@ -190,8 +189,7 @@ namespace SyncTrayzor.Syncthing.TransferHistory
                 if (this.completedTransfers.Count > maxCompletedTransfers)
                     this.completedTransfers.Dequeue();
 
-                List<FileTransfer> recentlySynchronizedList;
-                if (!this.recentlySynchronized.TryGetValue(fileTransfer.FolderId, out recentlySynchronizedList))
+                if (!this.recentlySynchronized.TryGetValue(fileTransfer.FolderId, out var recentlySynchronizedList))
                 {
                     recentlySynchronizedList = new List<FileTransfer>();
                     this.recentlySynchronized[fileTransfer.FolderId] = recentlySynchronizedList;
@@ -268,8 +266,7 @@ namespace SyncTrayzor.Syncthing.TransferHistory
 
         private void OnFolderSynchronizationFinished(string folderId, List<FileTransfer> fileTransfers)
         {
-            Folder folder;
-            if (!this.folderManager.TryFetchById(folderId, out folder))
+            if (!this.folderManager.TryFetchById(folderId, out var folder))
                 return;
 
             this.eventDispatcher.Raise(this.FolderSynchronizationFinished, new FolderSynchronizationFinishedEventArgs(folder, fileTransfers));

+ 3 - 3
src/SyncTrayzor/Syncthing/TransientWrapper.cs

@@ -20,7 +20,7 @@ namespace SyncTrayzor.Syncthing
         protected T _value;
         public virtual T Value
         {
-            get { return this._value; }
+            get => this._value;
             set
             {
                 var oldValue = this._value;
@@ -87,8 +87,8 @@ namespace SyncTrayzor.Syncthing
 
         public T UnsynchronizedValue
         {
-            get { return base.Value; }
-            set { base.Value = value; }
+            get => base.Value;
+            set => base.Value = value;
         }
 
         public SynchronizedTransientWrapper()

+ 2 - 7
src/SyncTrayzor/Utils/AtomicFileStream.cs

@@ -19,13 +19,8 @@ namespace SyncTrayzor.Utils
         public AtomicFileStream(string path, string tempPath)
             : base(tempPath, FileMode.Create, FileAccess.ReadWrite)
         {
-            if (path == null)
-                throw new ArgumentNullException("path");
-            if (tempPath == null)
-                throw new ArgumentNullException("tempPath");
-
-            this.path = path;
-            this.tempPath = tempPath;
+            this.path = path ?? throw new ArgumentNullException("path");
+            this.tempPath = tempPath ?? throw new ArgumentNullException("tempPath");
         }
 
         private static string TempFilePath(string path)

+ 1 - 2
src/SyncTrayzor/Utils/DotNetVersionFinder.cs

@@ -38,8 +38,7 @@ namespace SyncTrayzor.Utils
 
         private static string DescriptionForReleaseKey(int releaseKey)
         {
-            string description;
-            if (!versionMapping.TryGetValue(releaseKey, out description))
+            if (!versionMapping.TryGetValue(releaseKey, out var description))
                 description = "Unknown";
 
             return description;

+ 1 - 4
src/SyncTrayzor/Utils/LimitedConcurrencyTaskScheduler.cs

@@ -117,10 +117,7 @@ namespace SyncTrayzor.Utils
         }
 
         // Gets the maximum concurrency level supported by this scheduler.  
-        public sealed override int MaximumConcurrencyLevel
-        {
-            get { return this.maxDegreeOfParallelism; }
-        }
+        public sealed override int MaximumConcurrencyLevel => this.maxDegreeOfParallelism;
 
         // Gets an enumerable of the tasks currently scheduled on this scheduler.  
         protected sealed override IEnumerable<Task> GetScheduledTasks()

+ 2 - 2
src/SyncTrayzor/Utils/ShellTools.cs

@@ -12,8 +12,8 @@ namespace SyncTrayzor.Utils
 
         public static Icon GetIcon(string path, bool isFile)
         {
-            var flags = (uint)(SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON);
-            var attribute = isFile ? (uint)FILE_ATTRIBUTE_FILE : (uint)FILE_ATTRIBUTE_DIRECTORY;
+            var flags = SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON;
+            var attribute = isFile ? FILE_ATTRIBUTE_FILE : FILE_ATTRIBUTE_DIRECTORY;
             var shfi = new SHFileInfo();
             IntPtr res;
             try

+ 0 - 2
src/SyncTrayzor/Utils/StringExtensions.cs

@@ -1,8 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace SyncTrayzor.Utils
 {

+ 4 - 2
src/SyncTrayzor/Utils/UriExtensions.cs

@@ -8,8 +8,10 @@ namespace SyncTrayzor.Utils
         {
             if (uri.Host == "0.0.0.0")
             {
-                var builder = new UriBuilder(uri);
-                builder.Host = "127.0.0.1";
+                var builder = new UriBuilder(uri)
+                {
+                    Host = "127.0.0.1"
+                };
                 uri = builder.Uri;
             }
             return uri;

+ 2 - 2
src/SyncTrayzor/Xaml/ActivateBehaviour.cs

@@ -10,8 +10,8 @@ namespace SyncTrayzor.Xaml
 
         public IObservable<bool> ActivateObservable
         {
-            get { return (IObservable<bool>)GetValue(ActivateObservableProperty); }
-            set { SetValue(ActivateObservableProperty, value); }
+            get => (IObservable<bool>)GetValue(ActivateObservableProperty);
+            set => SetValue(ActivateObservableProperty, value);
         }
 
         public static readonly DependencyProperty ActivateObservableProperty =

+ 6 - 6
src/SyncTrayzor/Xaml/CollapsingRowDefinitionBehaviour.cs

@@ -9,24 +9,24 @@ namespace SyncTrayzor.Xaml
     {
         public GridLength Height
         {
-            get { return (GridLength)GetValue(HeightProperty); }
-            set { SetValue(HeightProperty, value); }
+            get => (GridLength)GetValue(HeightProperty);
+            set => SetValue(HeightProperty, value);
         }
         public static readonly DependencyProperty HeightProperty =
             DependencyProperty.Register("Height", typeof(GridLength), typeof(CollapsingRowDefinitionBehaviour), new PropertyMetadata(GridLength.Auto));
 
         public double MinHeight
         {
-            get { return (double)GetValue(MinHeightProperty); }
-            set { SetValue(MinHeightProperty, value); }
+            get => (double)GetValue(MinHeightProperty);
+            set => SetValue(MinHeightProperty, value);
         }
         public static readonly DependencyProperty MinHeightProperty =
             DependencyProperty.Register("MinHeight", typeof(double), typeof(CollapsingRowDefinitionBehaviour), new PropertyMetadata(0.0));
 
         public Visibility RowVisibility
         {
-            get { return (Visibility)GetValue(RowVisibilityProperty); }
-            set { SetValue(RowVisibilityProperty, value); }
+            get => (Visibility)GetValue(RowVisibilityProperty);
+            set => SetValue(RowVisibilityProperty, value);
         }
         public static readonly DependencyProperty RowVisibilityProperty =
             DependencyProperty.Register("RowVisibility", typeof(Visibility), typeof(CollapsingRowDefinitionBehaviour), new PropertyMetadata(Visibility.Visible, (d, e) =>

+ 1 - 2
src/SyncTrayzor/Xaml/GridViewSortByBehaviour.cs

@@ -117,8 +117,7 @@ namespace SyncTrayzor.Xaml
             if (initialSortColumn == null)
                 return;
 
-            var header = initialSortColumn.Header as GridViewColumnHeader;
-            if (header != null)
+            if (initialSortColumn.Header is GridViewColumnHeader header)
                 this.ApplyColumnSort(header, initialSortColumn, ListSortDirection.Ascending);
         }
 

+ 4 - 6
src/SyncTrayzor/Xaml/PopupConductorBehaviour.cs

@@ -9,8 +9,8 @@ namespace SyncTrayzor.Xaml
     {
         public object DataContext
         {
-            get { return (object)GetValue(DataContextProperty); }
-            set { SetValue(DataContextProperty, value); }
+            get => GetValue(DataContextProperty);
+            set => SetValue(DataContextProperty, value);
         }
 
         public static readonly DependencyProperty DataContextProperty =
@@ -30,15 +30,13 @@ namespace SyncTrayzor.Xaml
 
         private void Opened(object sender, EventArgs e)
         {
-            var screenState = this.DataContext as IScreenState;
-            if (screenState != null)
+            if (this.DataContext is IScreenState screenState)
                 screenState.Activate();
         }
 
         private void Closed(object sender, EventArgs e)
         {
-            var screenState = this.DataContext as IScreenState;
-            if (screenState != null)
+            if (this.DataContext is IScreenState screenState)
                 screenState.Close();
         }
     }

+ 1 - 2
src/SyncTrayzor/Xaml/TextBoxUtilities.cs

@@ -11,8 +11,7 @@ namespace SyncTrayzor.Xaml
 
         private static void AlwaysScrollToEndChanged(object sender, DependencyPropertyChangedEventArgs e)
         {
-            TextBox tb = sender as TextBox;
-            if (tb != null)
+            if (sender is TextBox tb)
             {
                 bool alwaysScrollToEnd = (e.NewValue != null) && (bool)e.NewValue;
                 if (alwaysScrollToEnd)

+ 5 - 4
src/SyncTrayzor/Xaml/UacImageSource.cs

@@ -13,9 +13,10 @@ namespace SyncTrayzor.Xaml
 
         static UacImageSource()
         {
-            SHSTOCKICONINFO sii = new SHSTOCKICONINFO();
-            sii.cbSize = (UInt32)Marshal.SizeOf(typeof(SHSTOCKICONINFO));
-
+            SHSTOCKICONINFO sii = new SHSTOCKICONINFO()
+            {
+                cbSize = (UInt32)Marshal.SizeOf(typeof(SHSTOCKICONINFO))
+            };
             Marshal.ThrowExceptionForHR(NativeMethods.SHGetStockIconInfo(SHSTOCKICONID.SIID_SHIELD,
                 SHGSI.SHGSI_ICON | SHGSI.SHGSI_SMALLICON,
                 ref sii));
@@ -25,7 +26,7 @@ namespace SyncTrayzor.Xaml
             NativeMethods.DestroyIcon(sii.hIcon);
         }
 
-        [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
         private struct SHSTOCKICONINFO
         {
             public UInt32 cbSize;

+ 8 - 8
src/SyncTrayzor/Xaml/WindowPlacementBehaviour.cs

@@ -15,8 +15,8 @@ namespace SyncTrayzor.Xaml
 
         public WindowPlacement Placement
         {
-            get { return (WindowPlacement)GetValue(PlacementProperty); }
-            set { SetValue(PlacementProperty, value); }
+            get => (WindowPlacement)GetValue(PlacementProperty);
+            set => SetValue(PlacementProperty, value);
         }
 
         public static readonly DependencyProperty PlacementProperty =
@@ -54,13 +54,13 @@ namespace SyncTrayzor.Xaml
                 length = Marshal.SizeOf(typeof(WINDOWPLACEMENT)),
                 flags = 0,
                 showCmd = this.Placement.IsMaximised ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL,
-                maxPosition = new POINT((int)this.Placement.MaxPosition.X, (int)this.Placement.MaxPosition.Y),
-                minPosition = new POINT((int)this.Placement.MinPosition.X, (int)this.Placement.MinPosition.Y),
+                maxPosition = new POINT(this.Placement.MaxPosition.X, this.Placement.MaxPosition.Y),
+                minPosition = new POINT(this.Placement.MinPosition.X, this.Placement.MinPosition.Y),
                 normalPosition = new RECT(
-                    (int)this.Placement.NormalPosition.Left,
-                    (int)this.Placement.NormalPosition.Top,
-                    (int)this.Placement.NormalPosition.Right,
-                    (int)this.Placement.NormalPosition.Bottom),
+                    this.Placement.NormalPosition.Left,
+                    this.Placement.NormalPosition.Top,
+                    this.Placement.NormalPosition.Right,
+                    this.Placement.NormalPosition.Bottom),
             };
 
             if (!NativeMethods.SetWindowPlacement(new WindowInteropHelper(this.AssociatedObject).Handle, ref nativePlacement))