Suppressing CLS compliance errors

Some functions and procedures require CLS
non-compliance due to file formats and the like.
Suppressing these compiler warnings
This commit is contained in:
Terry MacDonald 2021-01-28 21:19:20 +13:00
parent 0afe349eea
commit 3ecababc73
6 changed files with 46 additions and 26 deletions

View File

@ -52,7 +52,7 @@ namespace DesktopNotifications
{ {
public class DesktopNotificationManagerCompat 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 bool _registeredAumidAndComServer;
private static string _aumid; private static string _aumid;
@ -198,7 +198,9 @@ namespace DesktopNotifications
/// Creates a toast notifier. You must have called <see cref="RegisterActivator{T}"/> first (and also <see cref="RegisterAumidAndComServer(string)"/> if you're a classic Win32 app), or this will throw an exception. /// Creates a toast notifier. You must have called <see cref="RegisterActivator{T}"/> first (and also <see cref="RegisterAumidAndComServer(string)"/> if you're a classic Win32 app), or this will throw an exception.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
#pragma warning disable CS3002 // Return type is not CLS-compliant
public static ToastNotifier CreateToastNotifier() public static ToastNotifier CreateToastNotifier()
#pragma warning restore CS3002 // Return type is not CLS-compliant
{ {
EnsureRegistered(); EnsureRegistered();
@ -353,8 +355,9 @@ namespace DesktopNotifications
/// Gets all notifications sent by this app that are currently still in Action Center. /// Gets all notifications sent by this app that are currently still in Action Center.
/// </summary> /// </summary>
/// <returns>A collection of toasts.</returns> /// <returns>A collection of toasts.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] #pragma warning disable CS3002 // Return type is not CLS-compliant
public IReadOnlyList<ToastNotification> GetHistory() public IReadOnlyList<ToastNotification> GetHistory()
#pragma warning restore CS3002 // Return type is not CLS-compliant
{ {
return _aumid != null ? _history.GetHistory(_aumid) : _history.GetHistory(); return _aumid != null ? _history.GetHistory(_aumid) : _history.GetHistory();
} }

View File

@ -8,10 +8,12 @@ using ValveKeyValue;
namespace DisplayMagician.GameLibraries.SteamAppInfoParser namespace DisplayMagician.GameLibraries.SteamAppInfoParser
{ {
#pragma warning disable CS3003 // Type is not CLS-compliant
public class App public class App
{ {
public uint AppID { get; set; } public uint AppID { get; set; }
public uint Size { get; set; } public uint Size { get; set; }
public uint InfoState { get; set; } public uint InfoState { get; set; }
@ -26,4 +28,6 @@ namespace DisplayMagician.GameLibraries.SteamAppInfoParser
public KVObject Data { get; set; } public KVObject Data { get; set; }
} }
#pragma warning restore CS3003 // Type is not CLS-compliant
} }

View File

@ -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) 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) foreach (UplayGame testUplayGame in _allUplayGames)
{ {

View File

@ -95,11 +95,13 @@ namespace DisplayMagician
private bool _autoName = true; private bool _autoName = true;
private bool _isPossible; private bool _isPossible;
private List<StartProgram> _startPrograms; private List<StartProgram> _startPrograms;
[JsonIgnore]
public string _originalIconPath;
private Bitmap _shortcutBitmap, _originalLargeBitmap, _originalSmallBitmap; private Bitmap _shortcutBitmap, _originalLargeBitmap, _originalSmallBitmap;
[JsonIgnore] [JsonIgnore]
#pragma warning disable CS3008 // Identifier is not CLS-compliant
public string _originalIconPath;
[JsonIgnore]
public string _savedShortcutIconCacheFilename; public string _savedShortcutIconCacheFilename;
#pragma warning restore CS3008 // Identifier is not CLS-compliant
public ShortcutItem() public ShortcutItem()
{ {
@ -129,7 +131,9 @@ namespace DisplayMagician
public ShortcutItem( public ShortcutItem(
string name, string name,
#pragma warning disable CS3001 // Argument type is not CLS-compliant
ProfileItem profile, ProfileItem profile,
#pragma warning restore CS3001 // Argument type is not CLS-compliant
ShortcutPermanence displayPermanence, ShortcutPermanence displayPermanence,
ShortcutPermanence audioPermanence, ShortcutPermanence audioPermanence,
ShortcutPermanence capturePermanence, ShortcutPermanence capturePermanence,
@ -250,7 +254,9 @@ namespace DisplayMagician
public ShortcutItem( public ShortcutItem(
string name, string name,
#pragma warning disable CS3001 // Argument type is not CLS-compliant
ProfileItem profile, ProfileItem profile,
#pragma warning restore CS3001 // Argument type is not CLS-compliant
int gameAppId, int gameAppId,
string gameName, string gameName,
SupportedGameLibrary gameLibrary, SupportedGameLibrary gameLibrary,
@ -316,7 +322,9 @@ namespace DisplayMagician
public ShortcutItem( public ShortcutItem(
string name, string name,
#pragma warning disable CS3001 // Argument type is not CLS-compliant
ProfileItem profile, ProfileItem profile,
#pragma warning restore CS3001 // Argument type is not CLS-compliant
GameStruct game, GameStruct game,
ShortcutPermanence displayPermanence, ShortcutPermanence displayPermanence,
ShortcutPermanence audioPermanence, ShortcutPermanence audioPermanence,
@ -451,7 +459,9 @@ namespace DisplayMagician
public ShortcutItem( public ShortcutItem(
string name, string name,
#pragma warning disable CS3001 // Argument type is not CLS-compliant
ProfileItem profile, ProfileItem profile,
#pragma warning restore CS3001 // Argument type is not CLS-compliant
string differentExecutableToMonitor, string differentExecutableToMonitor,
string executableNameAndPath, string executableNameAndPath,
int executableTimeout, int executableTimeout,
@ -517,7 +527,9 @@ namespace DisplayMagician
public ShortcutItem( public ShortcutItem(
string name, string name,
#pragma warning disable CS3001 // Argument type is not CLS-compliant
ProfileItem profile, ProfileItem profile,
#pragma warning restore CS3001 // Argument type is not CLS-compliant
Executable executable, Executable executable,
ShortcutPermanence displayPermanence, ShortcutPermanence displayPermanence,
ShortcutPermanence audioPermanence, ShortcutPermanence audioPermanence,
@ -706,7 +718,9 @@ namespace DisplayMagician
[JsonIgnore] [JsonIgnore]
#pragma warning disable CS3003 // Type is not CLS-compliant
public ProfileItem ProfileToUse { public ProfileItem ProfileToUse {
#pragma warning restore CS3003 // Type is not CLS-compliant
get get
{ {
return _profileToUse; return _profileToUse;
@ -1136,7 +1150,9 @@ namespace DisplayMagician
public void UpdateNoGameShortcut( public void UpdateNoGameShortcut(
string name, string name,
#pragma warning disable CS3001 // Argument type is not CLS-compliant
ProfileItem profile, ProfileItem profile,
#pragma warning restore CS3001 // Argument type is not CLS-compliant
ShortcutPermanence displayPermanence, ShortcutPermanence displayPermanence,
ShortcutPermanence audioPermanence, ShortcutPermanence audioPermanence,
ShortcutPermanence capturePermanence, ShortcutPermanence capturePermanence,
@ -1260,7 +1276,9 @@ namespace DisplayMagician
public void UpdateGameShortcut( public void UpdateGameShortcut(
string name, string name,
#pragma warning disable CS3001 // Argument type is not CLS-compliant
ProfileItem profile, ProfileItem profile,
#pragma warning restore CS3001 // Argument type is not CLS-compliant
int gameAppId, int gameAppId,
string gameName, string gameName,
SupportedGameLibrary gameLibrary, SupportedGameLibrary gameLibrary,
@ -1327,7 +1345,9 @@ namespace DisplayMagician
public void UpdateGameShortcut( public void UpdateGameShortcut(
string name, string name,
#pragma warning disable CS3001 // Argument type is not CLS-compliant
ProfileItem profile, ProfileItem profile,
#pragma warning restore CS3001 // Argument type is not CLS-compliant
GameStruct game, GameStruct game,
ShortcutPermanence displayPermanence, ShortcutPermanence displayPermanence,
ShortcutPermanence audioPermanence, ShortcutPermanence audioPermanence,
@ -1465,7 +1485,9 @@ namespace DisplayMagician
public void UpdateExecutableShortcut( public void UpdateExecutableShortcut(
string name, string name,
#pragma warning disable CS3001 // Argument type is not CLS-compliant
ProfileItem profile, ProfileItem profile,
#pragma warning restore CS3001 // Argument type is not CLS-compliant
string differentExecutableToMonitor, string differentExecutableToMonitor,
string executableNameAndPath, string executableNameAndPath,
int executableTimeout, int executableTimeout,
@ -1532,7 +1554,9 @@ namespace DisplayMagician
public void UpdateExecutableShortcut( public void UpdateExecutableShortcut(
string name, string name,
#pragma warning disable CS3001 // Argument type is not CLS-compliant
ProfileItem profile, ProfileItem profile,
#pragma warning restore CS3001 // Argument type is not CLS-compliant
Executable executable, Executable executable,
ShortcutPermanence displayPermanence, ShortcutPermanence displayPermanence,
ShortcutPermanence audioPermanence, ShortcutPermanence audioPermanence,
@ -1872,9 +1896,11 @@ namespace DisplayMagician
return combinedBitmap; return combinedBitmap;
} }
#pragma warning disable CS3002 // Return type is not CLS-compliant
public MultiIcon ToIconOverlay() 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(256, 256),
new Size(64, 64), new Size(64, 64),
@ -1883,10 +1909,10 @@ namespace DisplayMagician
new Size(24, 24), new Size(24, 24),
new Size(16, 16) new Size(16, 16)
}; };
var multiIcon = new MultiIcon(); MultiIcon multiIcon = new MultiIcon();
var icon = multiIcon.Add("Icon1"); 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); Bitmap bitmapOverlay = ToBitmapOverlay(_originalLargeBitmap, ProfileToUse.ProfileTightestBitmap, size.Width, size.Height);
icon.Add(bitmapOverlay); icon.Add(bitmapOverlay);

View File

@ -114,11 +114,11 @@ namespace DisplayMagician.UIForms
} }
public uint GameTimeout public int GameTimeout
{ {
get get
{ {
return (uint)nud_timeout_game.Value; return (int)nud_timeout_game.Value;
} }
set 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 // Load all the profiles to prepare things

View File

@ -283,7 +283,7 @@ namespace DisplayMagicianShared
{ {
if (Paths != null && if (Paths != null &&
ProfileIcon is Bitmap && ProfileIcon is ProfileIcon &&
File.Exists(SavedProfileIconCacheFilename) && File.Exists(SavedProfileIconCacheFilename) &&
ProfileBitmap is Bitmap && ProfileBitmap is Bitmap &&
ProfileTightestBitmap is Bitmap && ProfileTightestBitmap is Bitmap &&