From 26d7777577236c4065801f9d06fa87e1b9f66f24 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Thu, 8 Jun 2023 22:32:13 +0500 Subject: [PATCH] Resolve build errors Signed-off-by: Octol1ttle --- .github/workflows/resharper.yml | 2 +- ColorsList.cs | 19 +++++++++++-------- Commands/BanCommand.cs | 3 +++ Extensions.cs | 3 ++- Services/UtilityService.cs | 6 ++++-- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/resharper.yml b/.github/workflows/resharper.yml index 452bd51..a50cbbe 100644 --- a/.github/workflows/resharper.yml +++ b/.github/workflows/resharper.yml @@ -29,5 +29,5 @@ jobs: uses: muno92/resharper_inspectcode@1.6.13 with: solutionPath: ./Boyfriend.sln - ignoreIssueType: InvertIf + ignoreIssueType: InvertIf,ConvertIfStatementToReturnStatement solutionWideAnalysis: true diff --git a/ColorsList.cs b/ColorsList.cs index c2dc416..c3da86b 100644 --- a/ColorsList.cs +++ b/ColorsList.cs @@ -1,15 +1,18 @@ using System.Drawing; +// ReSharper disable UnusedMember.Global +// TODO: remove this when all colors are used + namespace Boyfriend; public static class ColorsList { public static readonly Color Default = Color.Gray; - public static readonly Color Red = Color.Firebrick; - public static readonly Color Green = Color.PaleGreen; - public static readonly Color Yellow = Color.Gold; - public static readonly Color Blue = Color.RoyalBlue; - public static readonly Color Magneta = Color.Orchid; - public static readonly Color Cyan = Color.LightSkyBlue; - public static readonly Color Black = Color.Black; - public static readonly Color White = Color.WhiteSmoke; + public static readonly Color Red = Color.Firebrick; + public static readonly Color Green = Color.PaleGreen; + public static readonly Color Yellow = Color.Gold; + public static readonly Color Blue = Color.RoyalBlue; + public static readonly Color Magenta = Color.Orchid; + public static readonly Color Cyan = Color.LightSkyBlue; + public static readonly Color Black = Color.Black; + public static readonly Color White = Color.WhiteSmoke; } diff --git a/Commands/BanCommand.cs b/Commands/BanCommand.cs index 24e5678..0267a21 100644 --- a/Commands/BanCommand.cs +++ b/Commands/BanCommand.cs @@ -13,6 +13,9 @@ using Remora.Discord.Commands.Feedback.Services; using Remora.Discord.Extensions.Embeds; using Remora.Results; +// ReSharper disable ClassNeverInstantiated.Global +// ReSharper disable UnusedMember.Global + namespace Boyfriend.Commands; public class BanCommand : CommandGroup { diff --git a/Extensions.cs b/Extensions.cs index 01bf9e1..8e4f0eb 100644 --- a/Extensions.cs +++ b/Extensions.cs @@ -89,6 +89,7 @@ public static class Extensions { public static TResult? MaxOrDefault( this IEnumerable source, Func selector) { - return source.Any() ? source.Max(selector) : default; + var list = source.ToList(); + return list.Any() ? list.Max(selector) : default; } } diff --git a/Services/UtilityService.cs b/Services/UtilityService.cs index 2129079..61a9396 100644 --- a/Services/UtilityService.cs +++ b/Services/UtilityService.cs @@ -62,8 +62,10 @@ public class UtilityService : IHostedService { var interacterRoles = roles.Where(r => interacter.Roles.Contains(r.ID)); var botRoles = roles.Where(r => currentMember.Roles.Contains(r.ID)); - var targetBotRoleDiff = targetRoles.MaxOrDefault(r => r.Position) - botRoles.Max(r => r.Position); - var targetInteracterRoleDiff = targetRoles.MaxOrDefault(r => r.Position) - interacterRoles.Max(r => r.Position); + var targetRolesList = targetRoles.ToList(); + var targetBotRoleDiff = targetRolesList.MaxOrDefault(r => r.Position) - botRoles.Max(r => r.Position); + var targetInteracterRoleDiff + = targetRolesList.MaxOrDefault(r => r.Position) - interacterRoles.Max(r => r.Position); if (targetInteracterRoleDiff >= 0) return Result.FromSuccess($"UserCannot{action}Target".Localized());