diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 84aa93664..8a731f5b9 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -277,7 +277,8 @@ namespace Flow.Launcher.Plugin.Program.Programs [Serializable] public class Application : IProgram { - public string UniqueIdentifier { get; set; } + private string _uid = string.Empty; + public string UniqueIdentifier { get => _uid; set => _uid = value == null ? string.Empty : value.ToLowerInvariant(); } public string DisplayName { get; set; } public string Description { get; set; } public string UserModelId { get; set; } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index c13b32e80..6d27e579e 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -23,7 +23,7 @@ namespace Flow.Launcher.Plugin.Program.Programs public class Win32 : IProgram, IEquatable { public string Name { get; set; } - public string UniqueIdentifier { get => _uid; set => _uid = value.ToLowerInvariant(); } // For path comparison + public string UniqueIdentifier { get => _uid; set => _uid = value == null ? string.Empty : value.ToLowerInvariant(); } // For path comparison public string IcoPath { get; set; } public string FullPath { get; set; } public string LnkResolvedPath { get; set; } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs index fb32fb892..571dc0017 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs @@ -15,37 +15,39 @@ namespace Flow.Launcher.Plugin.Program.Views.Models /// public class ProgramSource { - private string name; + private string name = string.Empty; + private string loc = string.Empty; + private string uniqueIdentifier = string.Empty; - private string loc; public string Location { get => loc; set { - loc = value; - UniqueIdentifier = value.ToLowerInvariant(); + loc = value ?? string.Empty; + UniqueIdentifier = value; } } - public string Name { get => name ?? new DirectoryInfo(Location).Name; set => name = value; } + + public string Name { get => name; set => name = value ?? string.Empty; } public bool Enabled { get; set; } = true; - public string UniqueIdentifier { get; private set; } + public string UniqueIdentifier + { + get => uniqueIdentifier; + private set + { + uniqueIdentifier = value == null ? string.Empty : value.ToLowerInvariant(); + } + } [JsonConstructor] public ProgramSource(string name, string location, bool enabled, string uniqueIdentifier) { - loc = location; - this.name = name; + loc = location ?? string.Empty; + Name = name; Enabled = enabled; - if (location.Equals(uniqueIdentifier, StringComparison.OrdinalIgnoreCase)) - { - UniqueIdentifier = location.ToLowerInvariant(); // To make sure old config can be reset to case-insensitive - } - else - { - UniqueIdentifier = uniqueIdentifier; // For uwp apps - } + UniqueIdentifier = uniqueIdentifier; } /// @@ -55,14 +57,15 @@ namespace Flow.Launcher.Plugin.Program.Views.Models /// enabled public ProgramSource(string location, bool enabled = true) { - loc = location; + loc = location ?? string.Empty; Enabled = enabled; - UniqueIdentifier = location.ToLowerInvariant(); // For path comparison + UniqueIdentifier = location; // For path comparison + Name = new DirectoryInfo(Location).Name; } public ProgramSource(IProgram source) { - loc = source.Location; + loc = source.Location ?? string.Empty; Name = source.Name; Enabled = source.Enabled; UniqueIdentifier = source.UniqueIdentifier;