From 3ecababc73b7b8fbb6350eee23a8a0327e5986ea Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Thu, 28 Jan 2021 21:19:20 +1300 Subject: [PATCH] Suppressing CLS compliance errors Some functions and procedures require CLS non-compliance due to file formats and the like. Suppressing these compiler warnings --- .../DesktopNotificationManagerCompat.cs | 7 +++- .../GameLibraries/SteamAppInfoParser/App.cs | 4 ++ DisplayMagician/GameLibraries/UplayLibrary.cs | 15 +------- DisplayMagician/ShortcutItem.cs | 38 ++++++++++++++++--- DisplayMagician/UIForms/ShortcutForm.cs | 6 +-- DisplayMagicianShared/ProfileItem.cs | 2 +- 6 files changed, 46 insertions(+), 26 deletions(-) diff --git a/DisplayMagician/DesktopNotificationManagerCompat.cs b/DisplayMagician/DesktopNotificationManagerCompat.cs index d1c9474..84d6da3 100644 --- a/DisplayMagician/DesktopNotificationManagerCompat.cs +++ b/DisplayMagician/DesktopNotificationManagerCompat.cs @@ -52,7 +52,7 @@ namespace DesktopNotifications { public class DesktopNotificationManagerCompat { - public const string TOAST_ACTIVATED_LAUNCH_ARG = "-ToastActivated"; + private const string TOAST_ACTIVATED_LAUNCH_ARG = "-ToastActivated"; private static bool _registeredAumidAndComServer; private static string _aumid; @@ -198,7 +198,9 @@ namespace DesktopNotifications /// Creates a toast notifier. You must have called first (and also if you're a classic Win32 app), or this will throw an exception. /// /// +#pragma warning disable CS3002 // Return type is not CLS-compliant public static ToastNotifier CreateToastNotifier() +#pragma warning restore CS3002 // Return type is not CLS-compliant { EnsureRegistered(); @@ -353,8 +355,9 @@ 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")] +#pragma warning disable CS3002 // Return type is not CLS-compliant public IReadOnlyList GetHistory() +#pragma warning restore CS3002 // Return type is not CLS-compliant { return _aumid != null ? _history.GetHistory(_aumid) : _history.GetHistory(); } diff --git a/DisplayMagician/GameLibraries/SteamAppInfoParser/App.cs b/DisplayMagician/GameLibraries/SteamAppInfoParser/App.cs index 3d7d168..d90d48a 100644 --- a/DisplayMagician/GameLibraries/SteamAppInfoParser/App.cs +++ b/DisplayMagician/GameLibraries/SteamAppInfoParser/App.cs @@ -8,10 +8,12 @@ using ValveKeyValue; namespace DisplayMagician.GameLibraries.SteamAppInfoParser { +#pragma warning disable CS3003 // Type is not CLS-compliant public class App { public uint AppID { get; set; } + public uint Size { get; set; } public uint InfoState { get; set; } @@ -26,4 +28,6 @@ namespace DisplayMagician.GameLibraries.SteamAppInfoParser public KVObject Data { get; set; } } +#pragma warning restore CS3003 // Type is not CLS-compliant + } diff --git a/DisplayMagician/GameLibraries/UplayLibrary.cs b/DisplayMagician/GameLibraries/UplayLibrary.cs index 1af575f..3d1b23f 100644 --- a/DisplayMagician/GameLibraries/UplayLibrary.cs +++ b/DisplayMagician/GameLibraries/UplayLibrary.cs @@ -269,19 +269,6 @@ namespace DisplayMagician.GameLibraries } - public static bool ContainsUplayGame(uint uplayGameId) - { - foreach (UplayGame testUplayGame in _allUplayGames) - { - if (uplayGameId == testUplayGame.Id) - return true; - } - - - return false; - - } - public static UplayGame GetUplayGame(string uplayGameNameOrUuid) { @@ -312,7 +299,7 @@ namespace DisplayMagician.GameLibraries } - public static UplayGame GetUplayGame(uint uplayGameId) + public static UplayGame GetUplayGame(int uplayGameId) { foreach (UplayGame testUplayGame in _allUplayGames) { diff --git a/DisplayMagician/ShortcutItem.cs b/DisplayMagician/ShortcutItem.cs index e99dad1..5e6c444 100644 --- a/DisplayMagician/ShortcutItem.cs +++ b/DisplayMagician/ShortcutItem.cs @@ -95,11 +95,13 @@ namespace DisplayMagician private bool _autoName = true; private bool _isPossible; private List _startPrograms; - [JsonIgnore] - public string _originalIconPath; private Bitmap _shortcutBitmap, _originalLargeBitmap, _originalSmallBitmap; [JsonIgnore] +#pragma warning disable CS3008 // Identifier is not CLS-compliant + public string _originalIconPath; + [JsonIgnore] public string _savedShortcutIconCacheFilename; +#pragma warning restore CS3008 // Identifier is not CLS-compliant public ShortcutItem() { @@ -129,7 +131,9 @@ namespace DisplayMagician public ShortcutItem( string name, +#pragma warning disable CS3001 // Argument type is not CLS-compliant ProfileItem profile, +#pragma warning restore CS3001 // Argument type is not CLS-compliant ShortcutPermanence displayPermanence, ShortcutPermanence audioPermanence, ShortcutPermanence capturePermanence, @@ -250,7 +254,9 @@ namespace DisplayMagician public ShortcutItem( string name, +#pragma warning disable CS3001 // Argument type is not CLS-compliant ProfileItem profile, +#pragma warning restore CS3001 // Argument type is not CLS-compliant int gameAppId, string gameName, SupportedGameLibrary gameLibrary, @@ -316,7 +322,9 @@ namespace DisplayMagician public ShortcutItem( string name, +#pragma warning disable CS3001 // Argument type is not CLS-compliant ProfileItem profile, +#pragma warning restore CS3001 // Argument type is not CLS-compliant GameStruct game, ShortcutPermanence displayPermanence, ShortcutPermanence audioPermanence, @@ -451,7 +459,9 @@ namespace DisplayMagician public ShortcutItem( string name, +#pragma warning disable CS3001 // Argument type is not CLS-compliant ProfileItem profile, +#pragma warning restore CS3001 // Argument type is not CLS-compliant string differentExecutableToMonitor, string executableNameAndPath, int executableTimeout, @@ -517,7 +527,9 @@ namespace DisplayMagician public ShortcutItem( string name, +#pragma warning disable CS3001 // Argument type is not CLS-compliant ProfileItem profile, +#pragma warning restore CS3001 // Argument type is not CLS-compliant Executable executable, ShortcutPermanence displayPermanence, ShortcutPermanence audioPermanence, @@ -706,7 +718,9 @@ namespace DisplayMagician [JsonIgnore] +#pragma warning disable CS3003 // Type is not CLS-compliant public ProfileItem ProfileToUse { +#pragma warning restore CS3003 // Type is not CLS-compliant get { return _profileToUse; @@ -1136,7 +1150,9 @@ namespace DisplayMagician public void UpdateNoGameShortcut( string name, +#pragma warning disable CS3001 // Argument type is not CLS-compliant ProfileItem profile, +#pragma warning restore CS3001 // Argument type is not CLS-compliant ShortcutPermanence displayPermanence, ShortcutPermanence audioPermanence, ShortcutPermanence capturePermanence, @@ -1260,7 +1276,9 @@ namespace DisplayMagician public void UpdateGameShortcut( string name, +#pragma warning disable CS3001 // Argument type is not CLS-compliant ProfileItem profile, +#pragma warning restore CS3001 // Argument type is not CLS-compliant int gameAppId, string gameName, SupportedGameLibrary gameLibrary, @@ -1327,7 +1345,9 @@ namespace DisplayMagician public void UpdateGameShortcut( string name, +#pragma warning disable CS3001 // Argument type is not CLS-compliant ProfileItem profile, +#pragma warning restore CS3001 // Argument type is not CLS-compliant GameStruct game, ShortcutPermanence displayPermanence, ShortcutPermanence audioPermanence, @@ -1465,7 +1485,9 @@ namespace DisplayMagician public void UpdateExecutableShortcut( string name, +#pragma warning disable CS3001 // Argument type is not CLS-compliant ProfileItem profile, +#pragma warning restore CS3001 // Argument type is not CLS-compliant string differentExecutableToMonitor, string executableNameAndPath, int executableTimeout, @@ -1532,7 +1554,9 @@ namespace DisplayMagician public void UpdateExecutableShortcut( string name, +#pragma warning disable CS3001 // Argument type is not CLS-compliant ProfileItem profile, +#pragma warning restore CS3001 // Argument type is not CLS-compliant Executable executable, ShortcutPermanence displayPermanence, ShortcutPermanence audioPermanence, @@ -1872,9 +1896,11 @@ namespace DisplayMagician return combinedBitmap; } +#pragma warning disable CS3002 // Return type is not CLS-compliant public MultiIcon ToIconOverlay() +#pragma warning restore CS3002 // Return type is not CLS-compliant { - var iconSizes = new[] + Size[] iconSizes = new[] { new Size(256, 256), new Size(64, 64), @@ -1883,10 +1909,10 @@ namespace DisplayMagician new Size(24, 24), new Size(16, 16) }; - var multiIcon = new MultiIcon(); - var icon = multiIcon.Add("Icon1"); + MultiIcon multiIcon = new MultiIcon(); + SingleIcon icon = multiIcon.Add("Icon1"); - foreach (var size in iconSizes) + foreach (Size size in iconSizes) { Bitmap bitmapOverlay = ToBitmapOverlay(_originalLargeBitmap, ProfileToUse.ProfileTightestBitmap, size.Width, size.Height); icon.Add(bitmapOverlay); diff --git a/DisplayMagician/UIForms/ShortcutForm.cs b/DisplayMagician/UIForms/ShortcutForm.cs index 43d4bae..bf35fcf 100644 --- a/DisplayMagician/UIForms/ShortcutForm.cs +++ b/DisplayMagician/UIForms/ShortcutForm.cs @@ -114,11 +114,11 @@ namespace DisplayMagician.UIForms } - public uint GameTimeout + public int GameTimeout { get { - return (uint)nud_timeout_game.Value; + return (int)nud_timeout_game.Value; } set { @@ -597,7 +597,7 @@ namespace DisplayMagician.UIForms } } - private async void ShortcutForm_Load(object sender, EventArgs e) + private void ShortcutForm_Load(object sender, EventArgs e) { // Load all the profiles to prepare things diff --git a/DisplayMagicianShared/ProfileItem.cs b/DisplayMagicianShared/ProfileItem.cs index 524b2b9..716726d 100644 --- a/DisplayMagicianShared/ProfileItem.cs +++ b/DisplayMagicianShared/ProfileItem.cs @@ -283,7 +283,7 @@ namespace DisplayMagicianShared { if (Paths != null && - ProfileIcon is Bitmap && + ProfileIcon is ProfileIcon && File.Exists(SavedProfileIconCacheFilename) && ProfileBitmap is Bitmap && ProfileTightestBitmap is Bitmap &&