From 49329b870e19e0f33e49e8b3e1a51fd5b2ce03d6 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Sat, 26 Dec 2020 21:46:32 +1300 Subject: [PATCH] Initial Code Analysis fixes Also fixed up the Setup properties file for x64 build configuration. --- DisplayMagician.sln | 17 +-- .../DesktopNotificationActivator.cs | 6 +- .../DesktopNotificationManagerCompat.cs | 4 + DisplayMagician/DisplayMagician.csproj | 4 +- DisplayMagician/DisplayRepresentation.cs | 2 +- DisplayMagician/GameLibraries/SteamGame.cs | 1 + DisplayMagician/GameLibraries/SteamLibrary.cs | 1 + DisplayMagician/GameLibraries/UplayGame.cs | 1 + DisplayMagician/GameLibraries/UplayLibrary.cs | 7 +- DisplayMagician/GlobalSuppressions.cs | Bin 0 -> 104308 bytes DisplayMagician/InterProcess/IPCClient.cs | 8 +- DisplayMagician/InterProcess/IPCService.cs | 4 + DisplayMagician/Program.cs | 31 ++++-- DisplayMagician/Properties/AssemblyInfo.cs | 5 +- DisplayMagician/ShortcutItem.cs | 15 +-- DisplayMagician/ShortcutRepository.cs | 24 ++--- .../UIForms/DisplayProfileForm.resx | 2 +- DisplayMagician/UIForms/MainForm.cs | 20 ++-- .../DisplayMagicianSetup.wixproj | 9 +- .../DisplayMagicianFilesFragment.wxs | 102 +++++++++--------- 20 files changed, 151 insertions(+), 112 deletions(-) create mode 100644 DisplayMagician/GlobalSuppressions.cs diff --git a/DisplayMagician.sln b/DisplayMagician.sln index 5e3eaaf..f703512 100644 --- a/DisplayMagician.sln +++ b/DisplayMagician.sln @@ -18,8 +18,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DisplayMagicianTests", "Dis EndProject Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "DisplayMagicianSetup", "DisplayMagicianSetup\DisplayMagicianSetup.wixproj", "{DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}" EndProject -Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "DisplayMagicianBootstrapper", "DisplayMagicianBootstrapper\DisplayMagicianBootstrapper.wixproj", "{59F3F084-EC7E-42D4-B0F4-8131B82BDB3B}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|AnyCPU = Debug|AnyCPU @@ -90,25 +88,18 @@ Global {D7AFD3CC-53BF-4991-ABFE-638A3F355310}.Release|x64.Build.0 = Release|Any CPU {D7AFD3CC-53BF-4991-ABFE-638A3F355310}.Release|x86.ActiveCfg = Release|Any CPU {D7AFD3CC-53BF-4991-ABFE-638A3F355310}.Release|x86.Build.0 = Release|Any CPU - {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Debug|AnyCPU.ActiveCfg = Debug|x86 - {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Debug|AnyCPU.Build.0 = Debug|x86 + {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Debug|AnyCPU.ActiveCfg = Debug|x64 + {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Debug|AnyCPU.Build.0 = Debug|x64 {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Debug|x64.ActiveCfg = Debug|x64 {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Debug|x64.Build.0 = Debug|x64 {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Debug|x86.ActiveCfg = Debug|x86 {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Debug|x86.Build.0 = Debug|x86 - {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Release|AnyCPU.ActiveCfg = Release|x86 + {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Release|AnyCPU.ActiveCfg = Release|x64 + {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Release|AnyCPU.Build.0 = Release|x64 {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Release|x64.ActiveCfg = Release|x64 {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Release|x64.Build.0 = Release|x64 {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Release|x86.ActiveCfg = Release|x86 {DFD22D4D-F2E4-4BA4-B32A-7A990A35BA08}.Release|x86.Build.0 = Release|x86 - {59F3F084-EC7E-42D4-B0F4-8131B82BDB3B}.Debug|AnyCPU.ActiveCfg = Debug|x86 - {59F3F084-EC7E-42D4-B0F4-8131B82BDB3B}.Debug|x64.ActiveCfg = Debug|x86 - {59F3F084-EC7E-42D4-B0F4-8131B82BDB3B}.Debug|x86.ActiveCfg = Debug|x86 - {59F3F084-EC7E-42D4-B0F4-8131B82BDB3B}.Debug|x86.Build.0 = Debug|x86 - {59F3F084-EC7E-42D4-B0F4-8131B82BDB3B}.Release|AnyCPU.ActiveCfg = Release|x86 - {59F3F084-EC7E-42D4-B0F4-8131B82BDB3B}.Release|x64.ActiveCfg = Release|x86 - {59F3F084-EC7E-42D4-B0F4-8131B82BDB3B}.Release|x86.ActiveCfg = Release|x86 - {59F3F084-EC7E-42D4-B0F4-8131B82BDB3B}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/DisplayMagician/DesktopNotificationActivator.cs b/DisplayMagician/DesktopNotificationActivator.cs index 4caed1c..cdb42f8 100644 --- a/DisplayMagician/DesktopNotificationActivator.cs +++ b/DisplayMagician/DesktopNotificationActivator.cs @@ -20,7 +20,7 @@ namespace DisplayMagician [Guid("56F14154-6339-4B94-8B82-80F78D5BCEAF"), ComVisible(true)] public class DesktopNotificationActivator : NotificationActivator { - public override void OnActivated(string invokedArgs, NotificationUserInput userInput, string appUserModelId) + public override void OnActivated(string arguments, NotificationUserInput userInput, string appUserModelId) { // Invoke the code we're running on the UI Thread to avoid // cross thread exceptions @@ -29,11 +29,11 @@ namespace DisplayMagician // This code is running on the main UI thread! // Parse the query string (using NuGet package QueryString.NET) - QueryString args = QueryString.Parse(invokedArgs); + QueryString args = QueryString.Parse(arguments); foreach (QueryStringParameter myArg in args) { - if (myArg.Name.Equals("action",StringComparison.InvariantCultureIgnoreCase)) + if (myArg.Name.Equals("action",StringComparison.OrdinalIgnoreCase)) { // See what action is being requested switch (args["action"].ToLowerInvariant()) diff --git a/DisplayMagician/DesktopNotificationManagerCompat.cs b/DisplayMagician/DesktopNotificationManagerCompat.cs index 5a1ed04..9aded0f 100644 --- a/DisplayMagician/DesktopNotificationManagerCompat.cs +++ b/DisplayMagician/DesktopNotificationManagerCompat.cs @@ -64,6 +64,7 @@ namespace DesktopNotifications /// under Desktop Bridge. Call this upon application startup, before calling any other APIs. /// /// An AUMID that uniquely identifies your application. + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")] public static void RegisterAumidAndComServer(string aumid) where T : NotificationActivator { @@ -127,6 +128,7 @@ namespace DesktopNotifications /// Registers the activator type as a COM server client so that Windows can launch your activator. /// /// Your implementation of NotificationActivator. Must have GUID and ComVisible attributes on class. + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")] public static void RegisterActivator() where T : NotificationActivator, new() { @@ -225,6 +227,7 @@ namespace DesktopNotifications } } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "RegisterAumidAndComServer")] private static void EnsureRegistered() { // If not registered AUMID yet @@ -350,6 +353,7 @@ namespace DesktopNotifications /// Gets all notifications sent by this app that are currently still in Action Center. /// /// A collection of toasts. + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] public IReadOnlyList GetHistory() { return _aumid != null ? _history.GetHistory(_aumid) : _history.GetHistory(); diff --git a/DisplayMagician/DisplayMagician.csproj b/DisplayMagician/DisplayMagician.csproj index 6367f51..90e53fb 100644 --- a/DisplayMagician/DisplayMagician.csproj +++ b/DisplayMagician/DisplayMagician.csproj @@ -51,7 +51,8 @@ prompt 4 false - true + false + BasicCorrectnessRules.ruleset Resources\DisplayMagician.ico @@ -97,6 +98,7 @@ + diff --git a/DisplayMagician/DisplayRepresentation.cs b/DisplayMagician/DisplayRepresentation.cs index fba445c..a601141 100644 --- a/DisplayMagician/DisplayRepresentation.cs +++ b/DisplayMagician/DisplayRepresentation.cs @@ -15,7 +15,7 @@ namespace DisplayMagician { Name = display.DeviceName; Path = display.DevicePath; - var index = Path.IndexOf("{", StringComparison.InvariantCultureIgnoreCase); + var index = Path.IndexOf("{", StringComparison.OrdinalIgnoreCase); if (index > 0) { diff --git a/DisplayMagician/GameLibraries/SteamGame.cs b/DisplayMagician/GameLibraries/SteamGame.cs index b0464b6..ae8e35a 100644 --- a/DisplayMagician/GameLibraries/SteamGame.cs +++ b/DisplayMagician/GameLibraries/SteamGame.cs @@ -128,6 +128,7 @@ namespace DisplayMagician.GameLibraries } } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] public bool CopyInto(SteamGame steamGame) { if (!(steamGame is SteamGame)) diff --git a/DisplayMagician/GameLibraries/SteamLibrary.cs b/DisplayMagician/GameLibraries/SteamLibrary.cs index ff51284..42e5e76 100644 --- a/DisplayMagician/GameLibraries/SteamLibrary.cs +++ b/DisplayMagician/GameLibraries/SteamLibrary.cs @@ -190,6 +190,7 @@ namespace DisplayMagician.GameLibraries } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] public static bool ContainsSteamGame(SteamGame steamGame) { if (!(steamGame is SteamGame)) diff --git a/DisplayMagician/GameLibraries/UplayGame.cs b/DisplayMagician/GameLibraries/UplayGame.cs index d601ba5..c8c05c1 100644 --- a/DisplayMagician/GameLibraries/UplayGame.cs +++ b/DisplayMagician/GameLibraries/UplayGame.cs @@ -129,6 +129,7 @@ namespace DisplayMagician.GameLibraries } }*/ + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] public bool CopyTo(UplayGame uplayGame) { if (!(uplayGame is UplayGame)) diff --git a/DisplayMagician/GameLibraries/UplayLibrary.cs b/DisplayMagician/GameLibraries/UplayLibrary.cs index b83d03f..cffdbac 100644 --- a/DisplayMagician/GameLibraries/UplayLibrary.cs +++ b/DisplayMagician/GameLibraries/UplayLibrary.cs @@ -173,6 +173,7 @@ namespace DisplayMagician.GameLibraries } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] public static bool ContainsUplayGame(UplayGame uplayGame) { if (!(uplayGame is UplayGame)) @@ -300,7 +301,7 @@ namespace DisplayMagician.GameLibraries // Go through every record and attempt to parse it foreach (string uplayEntry in uplayConfigFile) { // Skip any Uplay entry records that don't start with 'version:' - if (!uplayEntry.StartsWith("version:",StringComparison.InvariantCultureIgnoreCase)) + if (!uplayEntry.StartsWith("version:",StringComparison.OrdinalIgnoreCase)) continue; //Split the record into entrylines @@ -398,7 +399,7 @@ namespace DisplayMagician.GameLibraries if (gotGameFileName && gotGameId && gotGameIconPath && gotGameName) break; // This line contains the Game Name - if (uplayEntryLines[i].StartsWith(" name:", StringComparison.InvariantCultureIgnoreCase) && !gotGameName) + if (uplayEntryLines[i].StartsWith(" name:", StringComparison.OrdinalIgnoreCase) && !gotGameName) { mc = Regex.Matches(uplayEntryLines[i], @" name\: (.*)"); uplayGameAppInfo.GameName = mc[0].Groups[1].ToString(); @@ -409,7 +410,7 @@ namespace DisplayMagician.GameLibraries } gotGameName = true; } - else if (uplayEntryLines[i].StartsWith(" icon_image:", StringComparison.InvariantCultureIgnoreCase) && !gotGameIconPath) + else if (uplayEntryLines[i].StartsWith(" icon_image:", StringComparison.OrdinalIgnoreCase) && !gotGameIconPath) { mc = Regex.Matches(uplayEntryLines[i], @"icon_image: (.*)"); string iconImageFileName = mc[0].Groups[1].ToString(); diff --git a/DisplayMagician/GlobalSuppressions.cs b/DisplayMagician/GlobalSuppressions.cs new file mode 100644 index 0000000000000000000000000000000000000000..ecf3413190a6cca1e1c11b25d4048343448cf038 GIT binary patch literal 104308 zcmeHQZExE~65h`R`X2<}7Y9hyCMm9f(H`KqX(1qK(>T815EQK~$&MOZHYB;J`{VEK zd3LlWcSSBKS)@p55IBAzMegp*KJz~NzyH2Br)G+OLvv-$%%!!|!tVpzbBHUa_Onym$t%a^*4*IV1Xua=SM%?D%FyhaJ^Y1F znb;>@n{&L2@8R7e`=&kf7~|N(I}Xhg^A*0n!N^|WJrna0e@l;fWIy)~pPZQwc2rm9 z-*zM;JEtL@^T_;aJ~yA4Ce8OJ%;pN?9An1*e80hrpJBdl?98sQniH(n5bHX_Px6T= ze*1v+yT!^6%yWD72LE5;-w=Nxbtd>X#3yH#I`R&m7CqeAG2hv>zQjmA&PQ^LPhEq8 z!~3g3%VaF_w6~Tbr0VScPV&nXpS{GjJ4>?*{H2etQ@o+OFe`G*OMC4Cvk@NY+L2G~ z{ABJ^rD7>6o?|x&ZK|Z8d-EG*!A%Iz3Fn zG!1bD{YO>`PzDb+uyZL>DN(jRAuJLY8t|~37pk@7fZ%D_NkfmqP zerc!PDbhlgKFlU<&JNvH%04wu;cfUD+7f3-pAWhB652`!Ux|mI1HPs=fL31OW$0Kx z!E%0vxPKsT4`1P}^igqqtNR|r$Mg~Nq<7;d{6E92X{q)xYyNx@#jD7-{?o_ zntzy|7p_oa-v^JUy=7@1&EvUGtLS~Sp!3FZV)e!e?Cmi|O#SU~ql^dsKHC#7YIc(Lg_CkFGnyNh(r9%Gxl+V$`B#g%;M&W`)F z9leyQRca6PqR@}QILHi=cWC~???dcgC%u)*t484R{G*%LyFQg)D3zh9P!Fii3tm5! zscq~2U0(#fIs3N} z5{PpOO+PmBePoNYD`TX7-Yk6GVZ-;$5nL`z(GqAH$XZc7$VFnU6d40%FvqK?ez=GcALh|v9EWyK8W zApTNjjT0*tEq%2T82MvX8CPff{5wCVxWPqz9XBX4>=rUK*Vm^SLRA_Dk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ZJD(@}gJY97^FA3h-*s*Nz~|YszMFc3>@|1g3p>|8ao;7L zG7ZM*&W-BeI(13u0^YHs;b%IS9cRp$CNhXfn~an?AMfQl&~|Y1D7txnB+- ii-c3%N@uUK@Vs!A<7l_evcJZ7hxC1CFMf`hU;hX4vxXP| literal 0 HcmV?d00001 diff --git a/DisplayMagician/InterProcess/IPCClient.cs b/DisplayMagician/InterProcess/IPCClient.cs index 3aa65a3..8c66691 100644 --- a/DisplayMagician/InterProcess/IPCClient.cs +++ b/DisplayMagician/InterProcess/IPCClient.cs @@ -8,6 +8,9 @@ namespace DisplayMagician.InterProcess { internal class IPCClient : ClientBase, IService { + + private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + public IPCClient(Process process) : base( new ServiceEndpoint( @@ -71,9 +74,10 @@ namespace DisplayMagician.InterProcess { if (process.Id != thisProcess.Id) { + IPCClient processChannel = null; try { - var processChannel = new IPCClient(process); + processChannel = new IPCClient(process); if (processChannel.Status == status) { @@ -82,6 +86,8 @@ namespace DisplayMagician.InterProcess } catch (Exception ex) { + processChannel = null; + logger.Error(ex, $"IPCClient/QueryByStatus: Couldn't create an IPC Client"); Console.WriteLine($"IPCClient/QueryByStatus exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); // ignored } diff --git a/DisplayMagician/InterProcess/IPCService.cs b/DisplayMagician/InterProcess/IPCService.cs index 0a0dd7d..2b545b5 100644 --- a/DisplayMagician/InterProcess/IPCService.cs +++ b/DisplayMagician/InterProcess/IPCService.cs @@ -10,6 +10,8 @@ namespace DisplayMagician.InterProcess { private static ServiceHost _serviceHost; + private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + private IPCService() { Status = InstanceStatus.Busy; @@ -53,6 +55,7 @@ namespace DisplayMagician.InterProcess } catch (Exception ex) { + logger.Error(ex, $"IPCService/StartService exception: Couldn't create an IPC Service"); Console.WriteLine($"IPCService/StartService exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); try { @@ -60,6 +63,7 @@ namespace DisplayMagician.InterProcess } catch (Exception ex2) { + logger.Error(ex, $"IPCService/StartService exception: Couldn't close an IPC Service after error creating it"); Console.WriteLine($"IPCService/StartService exception 2: {ex2.Message}: {ex2.InnerException}"); // ignored } diff --git a/DisplayMagician/Program.cs b/DisplayMagician/Program.cs index af52eb5..4e49e61 100644 --- a/DisplayMagician/Program.cs +++ b/DisplayMagician/Program.cs @@ -13,10 +13,8 @@ using DisplayMagicianShared; using DisplayMagician.UIForms; using System.Text.RegularExpressions; using System.Drawing; -//using Microsoft.Toolkit.Uwp.Notifications; using DesktopNotifications; - -//using System.Runtime.InteropServices; +using System.Runtime.Serialization; namespace DisplayMagician { @@ -646,19 +644,40 @@ namespace DisplayMagician { public class ApplyTopologyException : Exception { - public ApplyTopologyException(String message) : base(message) + public ApplyTopologyException() + { } + + public ApplyTopologyException(string message) : base(message) + { } + + public ApplyTopologyException(string message, Exception innerException) : base(message, innerException) + { } + public ApplyTopologyException(SerializationInfo info, StreamingContext context) : base(info, context) { } } public class ApplyPathInfoException : Exception { - public ApplyPathInfoException(String message) : base(message) + public ApplyPathInfoException() + { } + + public ApplyPathInfoException(string message) : base(message) + { } + public ApplyPathInfoException(string message, Exception innerException) : base(message, innerException) + { } + public ApplyPathInfoException(SerializationInfo info, StreamingContext context) : base(info, context) { } } public class LoadingInstalledGamesException : Exception { - public LoadingInstalledGamesException(String message) : base(message) + public LoadingInstalledGamesException() + { } + public LoadingInstalledGamesException(string message) : base(message) + { } + public LoadingInstalledGamesException(string message, Exception innerException) : base(message, innerException) + { } + public LoadingInstalledGamesException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } \ No newline at end of file diff --git a/DisplayMagician/Properties/AssemblyInfo.cs b/DisplayMagician/Properties/AssemblyInfo.cs index 0ccc260..b94da0a 100644 --- a/DisplayMagician/Properties/AssemblyInfo.cs +++ b/DisplayMagician/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ -using System.Resources; +using System; +using System.Resources; using System.Reflection; using System.Runtime.InteropServices; @@ -39,3 +40,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyVersion("0.2.0.*")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: NeutralResourcesLanguage("en")] + +[assembly: CLSCompliant(true)] \ No newline at end of file diff --git a/DisplayMagician/ShortcutItem.cs b/DisplayMagician/ShortcutItem.cs index 5f9d0b4..cae499f 100644 --- a/DisplayMagician/ShortcutItem.cs +++ b/DisplayMagician/ShortcutItem.cs @@ -216,7 +216,7 @@ namespace DisplayMagician // Now we need to find and populate the profileToUse foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles) { - if (profileToTest.UUID.Equals(_profileUuid, StringComparison.InvariantCultureIgnoreCase)) + if (profileToTest.UUID.Equals(_profileUuid, StringComparison.OrdinalIgnoreCase)) { _profileToUse = profileToTest; break; @@ -419,7 +419,7 @@ namespace DisplayMagician // Now we need to find and populate the profileToUse foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles) { - if (profileToTest.UUID.Equals(_profileUuid,StringComparison.InvariantCultureIgnoreCase)) + if (profileToTest.UUID.Equals(_profileUuid,StringComparison.OrdinalIgnoreCase)) { _profileToUse = profileToTest; break; @@ -617,7 +617,7 @@ namespace DisplayMagician // Now we need to find and populate the profileToUse foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles) { - if (profileToTest.UUID.Equals(_profileUuid, StringComparison.InvariantCultureIgnoreCase)) + if (profileToTest.UUID.Equals(_profileUuid, StringComparison.OrdinalIgnoreCase)) { _profileToUse = profileToTest; break; @@ -729,7 +729,7 @@ namespace DisplayMagician // We try to find and set the ProfileTouse foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles) { - if (profileToTest.UUID.Equals(_profileUuid, StringComparison.InvariantCultureIgnoreCase)) + if (profileToTest.UUID.Equals(_profileUuid, StringComparison.OrdinalIgnoreCase)) _profileToUse = profileToTest; } } @@ -1224,7 +1224,7 @@ namespace DisplayMagician // Now we need to find and populate the profileToUse foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles) { - if (profileToTest.UUID.Equals(_profileUuid, StringComparison.InvariantCultureIgnoreCase)) + if (profileToTest.UUID.Equals(_profileUuid, StringComparison.OrdinalIgnoreCase)) { _profileToUse = profileToTest; break; @@ -1431,7 +1431,7 @@ namespace DisplayMagician // Now we need to find and populate the profileToUse foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles) { - if (profileToTest.UUID.Equals(_profileUuid, StringComparison.InvariantCultureIgnoreCase)) + if (profileToTest.UUID.Equals(_profileUuid, StringComparison.OrdinalIgnoreCase)) { _profileToUse = profileToTest; break; @@ -1634,7 +1634,7 @@ namespace DisplayMagician // Now we need to find and populate the profileToUse foreach (ProfileItem profileToTest in ProfileRepository.AllProfiles) { - if (profileToTest.UUID.Equals(_profileUuid, StringComparison.InvariantCultureIgnoreCase)) + if (profileToTest.UUID.Equals(_profileUuid, StringComparison.OrdinalIgnoreCase)) { _profileToUse = profileToTest; break; @@ -1821,6 +1821,7 @@ namespace DisplayMagician } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] public Bitmap ToBitmapOverlay(Bitmap originalBitmap, Bitmap overlayBitmap, int width, int height, PixelFormat format = PixelFormat.Format32bppArgb) { diff --git a/DisplayMagician/ShortcutRepository.cs b/DisplayMagician/ShortcutRepository.cs index f739551..6a4236a 100644 --- a/DisplayMagician/ShortcutRepository.cs +++ b/DisplayMagician/ShortcutRepository.cs @@ -136,7 +136,7 @@ namespace DisplayMagician return false; // Remove the Shortcut Icons from the Cache - List shortcutsToRemove = _allShortcuts.FindAll(item => item.UUID.Equals(shortcut.UUID, StringComparison.InvariantCultureIgnoreCase)); + List shortcutsToRemove = _allShortcuts.FindAll(item => item.UUID.Equals(shortcut.UUID, StringComparison.OrdinalIgnoreCase)); foreach (ShortcutItem shortcutToRemove in shortcutsToRemove) { try @@ -152,7 +152,7 @@ namespace DisplayMagician } // Remove the shortcut from the list. - int numRemoved = _allShortcuts.RemoveAll(item => item.UUID.Equals(shortcut.UUID, StringComparison.InvariantCultureIgnoreCase)); + int numRemoved = _allShortcuts.RemoveAll(item => item.UUID.Equals(shortcut.UUID, StringComparison.OrdinalIgnoreCase)); if (numRemoved == 1) { @@ -178,13 +178,13 @@ namespace DisplayMagician Match match = Regex.Match(shortcutNameOrUuid, uuidV4Regex, RegexOptions.IgnoreCase); if (match.Success) { - shortcutsToRemove = _allShortcuts.FindAll(item => item.UUID.Equals(shortcutNameOrUuid, StringComparison.InvariantCultureIgnoreCase)); - numRemoved = _allShortcuts.RemoveAll(item => item.UUID.Equals(shortcutNameOrUuid, StringComparison.InvariantCultureIgnoreCase)); + shortcutsToRemove = _allShortcuts.FindAll(item => item.UUID.Equals(shortcutNameOrUuid, StringComparison.OrdinalIgnoreCase)); + numRemoved = _allShortcuts.RemoveAll(item => item.UUID.Equals(shortcutNameOrUuid, StringComparison.OrdinalIgnoreCase)); } else { - shortcutsToRemove = _allShortcuts.FindAll(item => item.Name.Equals(shortcutNameOrUuid, StringComparison.InvariantCultureIgnoreCase)); - numRemoved = _allShortcuts.RemoveAll(item => item.Name.Equals(shortcutNameOrUuid, StringComparison.InvariantCultureIgnoreCase)); + shortcutsToRemove = _allShortcuts.FindAll(item => item.Name.Equals(shortcutNameOrUuid, StringComparison.OrdinalIgnoreCase)); + numRemoved = _allShortcuts.RemoveAll(item => item.Name.Equals(shortcutNameOrUuid, StringComparison.OrdinalIgnoreCase)); } // Remove the Shortcut Icons from the Cache foreach (ShortcutItem shortcutToRemove in shortcutsToRemove) @@ -221,7 +221,7 @@ namespace DisplayMagician foreach (ShortcutItem testShortcut in _allShortcuts) { - if (testShortcut.UUID.Equals(shortcut.UUID,StringComparison.InvariantCultureIgnoreCase)) + if (testShortcut.UUID.Equals(shortcut.UUID,StringComparison.OrdinalIgnoreCase)) return true; } @@ -240,7 +240,7 @@ namespace DisplayMagician { foreach (ShortcutItem testShortcut in _allShortcuts) { - if (testShortcut.UUID.Equals(shortcutNameOrUuid, StringComparison.InvariantCultureIgnoreCase)) + if (testShortcut.UUID.Equals(shortcutNameOrUuid, StringComparison.OrdinalIgnoreCase)) return true; } @@ -249,7 +249,7 @@ namespace DisplayMagician { foreach (ShortcutItem testShortcut in _allShortcuts) { - if (testShortcut.Name.Equals(shortcutNameOrUuid, StringComparison.InvariantCultureIgnoreCase)) + if (testShortcut.Name.Equals(shortcutNameOrUuid, StringComparison.OrdinalIgnoreCase)) return true; } @@ -271,7 +271,7 @@ namespace DisplayMagician { foreach (ShortcutItem testShortcut in _allShortcuts) { - if (testShortcut.UUID.Equals(shortcutNameOrUuid, StringComparison.InvariantCultureIgnoreCase)) + if (testShortcut.UUID.Equals(shortcutNameOrUuid, StringComparison.OrdinalIgnoreCase)) return testShortcut; } @@ -280,7 +280,7 @@ namespace DisplayMagician { foreach (ShortcutItem testShortcut in _allShortcuts) { - if (testShortcut.Name.Equals(shortcutNameOrUuid, StringComparison.InvariantCultureIgnoreCase)) + if (testShortcut.Name.Equals(shortcutNameOrUuid, StringComparison.OrdinalIgnoreCase)) return testShortcut; } @@ -297,7 +297,7 @@ namespace DisplayMagician foreach (ShortcutItem testShortcut in ShortcutRepository.AllShortcuts) { - if (testShortcut.ProfileUUID.Equals(newProfile.UUID, StringComparison.InvariantCultureIgnoreCase) && testShortcut.AutoName) + if (testShortcut.ProfileUUID.Equals(newProfile.UUID, StringComparison.OrdinalIgnoreCase) && testShortcut.AutoName) { testShortcut.ProfileToUse = newProfile; testShortcut.AutoSuggestShortcutName(); diff --git a/DisplayMagician/UIForms/DisplayProfileForm.resx b/DisplayMagician/UIForms/DisplayProfileForm.resx index 838c7b0..0f18ad5 100644 --- a/DisplayMagician/UIForms/DisplayProfileForm.resx +++ b/DisplayMagician/UIForms/DisplayProfileForm.resx @@ -157,7 +157,7 @@ - BorderColor = 406d6d6d; UnFocusedColor1 = ffff8080; UnFocusedColor2 = LightCoral; UnFocusedBorderColor = Maroon; HoverColor1 = 80078d7; HoverColor2 = 400078d7; HoverBorderColor = 400078d7; SelectedColor1 = ffff8080; SelectedColor2 = LightCoral; SelectedBorderColor = Maroon; DisabledColor1 = 6d6d6d; DisabledColor2 = 206d6d6d; DisabledBorderColor = 206d6d6d; DisabledForeColor = ff808080; ColumnHeaderBackColor1 = 20f0f0f0; ColumnHeaderBackColor2 = c4f0f0f0; ColumnHeaderHoverColor1 = 100078d7; ColumnHeaderHoverColor2 = 400078d7; ColumnSelectColor = 106d6d6d; ColumnSeparatorColor = 206d6d6d; PaneBackColor = 106d6d6d; PaneSeparatorColor = 806d6d6d; SelectionRectangleColor1 = 800078d7; SelectionRectangleColor2 = 800078d7 + BorderColor = 406d6d6d; UnfocusedColor1 = ffff8080; UnfocusedColor2 = LightCoral; UnfocusedBorderColor = Maroon; HoverColor1 = 80078d7; HoverColor2 = 400078d7; HoverBorderColor = 400078d7; SelectedColor1 = ffff8080; SelectedColor2 = LightCoral; SelectedBorderColor = Maroon; DisabledColor1 = 6d6d6d; DisabledColor2 = 206d6d6d; DisabledBorderColor = 206d6d6d; DisabledForeColor = ff808080; ColumnHeaderBackColor1 = 20f0f0f0; ColumnHeaderBackColor2 = c4f0f0f0; ColumnHeaderHoverColor1 = 100078d7; ColumnHeaderHoverColor2 = 400078d7; ColumnSelectColor = 106d6d6d; ColumnSeparatorColor = 206d6d6d; PaneBackColor = 106d6d6d; PaneSeparatorColor = 806d6d6d; SelectionRectangleColor1 = 800078d7; SelectionRectangleColor2 = 800078d7 248, 17 diff --git a/DisplayMagician/UIForms/MainForm.cs b/DisplayMagician/UIForms/MainForm.cs index 3b82cc8..21c4ad9 100644 --- a/DisplayMagician/UIForms/MainForm.cs +++ b/DisplayMagician/UIForms/MainForm.cs @@ -31,7 +31,9 @@ namespace DisplayMagician.UIForms private bool allowVisible; // ContextMenu's Show command used private bool allowClose; // ContextMenu's Exit command used - public MainForm(Form formToOpen = null, bool FromToast = false) + private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + + public MainForm(Form formToOpen = null) { InitializeComponent(); btn_setup_display_profiles.Parent = splitContainer1.Panel1; @@ -383,6 +385,7 @@ namespace DisplayMagician.UIForms DialogResult dialogResult; if (args.Mandatory.Value) { + logger.Info($"MainForm/AutoUpdaterOnCheckForUpdateEvent - New version {args.CurrentVersion} available. Current version is {args.InstalledVersion}. Mandatory upgrade."); dialogResult = MessageBox.Show( $@"There is new version {args.CurrentVersion} available. You are using version {args.InstalledVersion}. This is required update. Press Ok to begin updating the application.", @"Update Available", @@ -391,6 +394,7 @@ namespace DisplayMagician.UIForms } else { + logger.Info($"MainForm/AutoUpdaterOnCheckForUpdateEvent - New version {args.CurrentVersion} available. Current version is {args.InstalledVersion}. Optional upgrade."); dialogResult = MessageBox.Show( $@"There is new version {args.CurrentVersion} available. You are using version { @@ -407,34 +411,34 @@ namespace DisplayMagician.UIForms { try { + logger.Info($"MainForm/AutoUpdaterOnCheckForUpdateEvent - Downloading {args.InstalledVersion} update."); if (AutoUpdater.DownloadUpdate(args)) { + logger.Info($"MainForm/AutoUpdaterOnCheckForUpdateEvent - Restarting to apply {args.InstalledVersion} update."); Application.Exit(); } } - catch (Exception exception) + catch (Exception ex) { - MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, + logger.Warn(ex, $"MainForm/AutoUpdaterOnCheckForUpdateEvent - Exception during update download."); + MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } - /*else - { - MessageBox.Show(@"There is no update available please try again later.", @"No update available", - MessageBoxButtons.OK, MessageBoxIcon.Information); - }*/ } else { if (args.Error is WebException) { + logger.Warn(args.Error, $"MainForm/AutoUpdaterOnCheckForUpdateEvent - WebException - There was a problem reaching the update server."); MessageBox.Show( @"There is a problem reaching update server. Please check your internet connection and try again later.", @"Update Check Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { + logger.Warn(args.Error, $"MainForm/AutoUpdaterOnCheckForUpdateEvent - There was a problem performing the update: {args.Error.Message}"); MessageBox.Show(args.Error.Message, args.Error.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/DisplayMagicianSetup/DisplayMagicianSetup.wixproj b/DisplayMagicianSetup/DisplayMagicianSetup.wixproj index 72cc343..61a16d2 100644 --- a/DisplayMagicianSetup/DisplayMagicianSetup.wixproj +++ b/DisplayMagicianSetup/DisplayMagicianSetup.wixproj @@ -11,15 +11,16 @@ DisplayMagicianSetup - bin\$(Configuration)\ + bin\$(Platform)\$(Configuration)\ obj\$(Configuration)\ Debug;DisplayMagicianFilesDir=H:\vscode-projects\DisplayMagician\DisplayMagician\bin\Debug -arch x64 - bin\$(Configuration)\ + bin\$(Platform)\$(Configuration)\ obj\$(Configuration)\ - + -arch x64 + DisplayMagicianFilesDir=H:\vscode-projects\DisplayMagician\DisplayMagician\bin\Debug DisplayMagicianFilesDir=H:\vscode-projects\DisplayMagician\DisplayMagician\bin\Debug; @@ -36,7 +37,7 @@ obj\$(Platform)\$(Configuration)\ False True - DisplayMagicianFilesDir=H:\vscode-projects\DisplayMagician\Debug + DisplayMagicianFilesDir=H:\vscode-projects\DisplayMagician\DisplayMagician\bin\Debug diff --git a/DisplayMagicianSetup/Fragments/DisplayMagicianFilesFragment.wxs b/DisplayMagicianSetup/Fragments/DisplayMagicianFilesFragment.wxs index 7a2d1d1..10ce88f 100644 --- a/DisplayMagicianSetup/Fragments/DisplayMagicianFilesFragment.wxs +++ b/DisplayMagicianSetup/Fragments/DisplayMagicianFilesFragment.wxs @@ -2,196 +2,196 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +