clean up compiler warnings

This commit is contained in:
13xforever 2024-06-20 12:33:31 +05:00 committed by Haxy
parent 7d4d3ed89a
commit d6688fd0c4
8 changed files with 13 additions and 9 deletions

View File

@ -12,6 +12,7 @@ using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using Microsoft.EntityFrameworkCore;
using NLog;
namespace CompatBot.Commands;
@ -248,7 +249,7 @@ internal partial class Sudo
if (SandboxDetector.Detect() != SandboxType.Docker)
{
Config.Log.Info("Restarting...");
Config.Log.Factory.Flush();
LogManager.LogFactory.Flush();
using var self = new Process {StartInfo = RestartInfo};
self.Start();
Config.InMemorySettings["shutdown"] = "true";

View File

@ -16,6 +16,7 @@ using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity.Extensions;
using Microsoft.EntityFrameworkCore;
using NLog;
using SharpCompress.Common;
using SharpCompress.Compressors;
using SharpCompress.Compressors.Deflate;
@ -134,7 +135,7 @@ internal sealed partial class Sudo : BaseCommandModuleCustom
{
try
{
Config.Log.Factory.Flush();
LogManager.LogFactory.Flush();
string[] logPaths = [Config.CurrentLogPath];
if (DateTime.TryParse(date, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var logDate))
{

View File

@ -75,8 +75,10 @@ public static class DbImporter
{
// __EFMigrationsHistory table will be already created by the failed migration attempt
#pragma warning disable EF1001 // Internal EF Core API usage.
#pragma warning disable EF1002 // Using raw sql
await db.ExecuteSqlRawAsync($"INSERT INTO `__EFMigrationsHistory`(`MigrationId`,`ProductVersion`) VALUES ({new InitialCreate().GetId()},'manual')", cancellationToken);
await db.ExecuteSqlRawAsync($"INSERT INTO `__EFMigrationsHistory`(`MigrationId`,`ProductVersion`) VALUES ({new Explanations().GetId()},'manual')", cancellationToken);
#pragma warning restore EF1002
#pragma warning restore EF1001 // Internal EF Core API usage.
// create constraints on moderator
await db.ExecuteSqlRawAsync(@"CREATE TABLE `temp_new_moderator` (

View File

@ -40,7 +40,7 @@ internal sealed class RarHandler: IArchiveHandler
while (rarReader.MoveToNextEntry())
{
if (!rarReader.Entry.IsDirectory
&& rarReader.Entry.Key.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& rarReader.Entry.Key!.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& !rarReader.Entry.Key.Contains("tty.log", StringComparison.InvariantCultureIgnoreCase))
{
LogSize = rarReader.Entry.Size;

View File

@ -40,7 +40,7 @@ internal sealed class SevenZipHandler: IArchiveHandler
using var zipReader = zipArchive.ExtractAllEntries();
while (zipReader.MoveToNextEntry())
if (!zipReader.Entry.IsDirectory
&& zipReader.Entry.Key.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& zipReader.Entry.Key!.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& !zipReader.Entry.Key.Contains("tty.log", StringComparison.InvariantCultureIgnoreCase))
{
LogSize = zipReader.Entry.Size;

View File

@ -41,7 +41,7 @@ internal sealed class ZipHandler: IArchiveHandler
while (zipReader.MoveToNextEntry())
{
if (!zipReader.Entry.IsDirectory
&& zipReader.Entry.Key.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& zipReader.Entry.Key!.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& !zipReader.Entry.Key.Contains("tty.log", StringComparison.InvariantCultureIgnoreCase))
{
LogSize = zipReader.Entry.Size;

View File

@ -50,7 +50,7 @@ internal static class ColorGetter
return defaultColor;
// TODO .net6 breaks this for linux
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (!OperatingSystem.IsWindowsVersionAtLeast(6, 1))
return defaultColor;
var analyzer = new ColorThief();

View File

@ -218,7 +218,7 @@ internal static class AzureDevOpsClientExtensions
using var zipStream = ReaderFactory.Open(stream);
while (zipStream.MoveToNextEntry() && !cancellationToken.IsCancellationRequested)
{
if (zipStream.Entry.Key.EndsWith(".7z", StringComparison.InvariantCultureIgnoreCase))
if (zipStream.Entry.Key?.EndsWith(".7z", StringComparison.InvariantCultureIgnoreCase) is true)
{
result = result with {WindowsFilename = Path.GetFileName(zipStream.Entry.Key)};
break;
@ -248,7 +248,7 @@ internal static class AzureDevOpsClientExtensions
using var zipStream = ReaderFactory.Open(stream);
while (zipStream.MoveToNextEntry() && !cancellationToken.IsCancellationRequested)
{
if (zipStream.Entry.Key.EndsWith(".AppImage", StringComparison.InvariantCultureIgnoreCase))
if (zipStream.Entry.Key?.EndsWith(".AppImage", StringComparison.InvariantCultureIgnoreCase) is true)
{
result = result with {LinuxFilename = Path.GetFileName(zipStream.Entry.Key)};
break;
@ -275,7 +275,7 @@ internal static class AzureDevOpsClientExtensions
using var zipStream = ReaderFactory.Open(stream);
while (zipStream.MoveToNextEntry() && !cancellationToken.IsCancellationRequested)
{
if (zipStream.Entry.Key.EndsWith(".dmg", StringComparison.InvariantCultureIgnoreCase))
if (zipStream.Entry.Key?.EndsWith(".dmg", StringComparison.InvariantCultureIgnoreCase) is true)
{
result = result with { MacFilename = Path.GetFileName(zipStream.Entry.Key) };
break;