mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-01-31 01:25:22 +01:00
fix compilation warnings after upgrading to dotnet core 3.0
This commit is contained in:
4
CompatBot/.editorconfig
Normal file
4
CompatBot/.editorconfig
Normal file
@@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# IDE0063: Use simple 'using' statement
|
||||
csharp_prefer_simple_using_statement = false:suggestion
|
||||
@@ -55,49 +55,51 @@ namespace CompatBot.Database
|
||||
try
|
||||
{
|
||||
// __EFMigrationsHistory table will be already created by the failed migration attempt
|
||||
await db.ExecuteSqlCommandAsync($"INSERT INTO `__EFMigrationsHistory`(`MigrationId`,`ProductVersion`) VALUES ({new InitialCreate().GetId()},'manual')", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync($"INSERT INTO `__EFMigrationsHistory`(`MigrationId`,`ProductVersion`) VALUES ({new Explanations().GetId()},'manual')", cancellationToken);
|
||||
#pragma warning disable EF1001 // Internal EF Core API usage.
|
||||
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 EF1001 // Internal EF Core API usage.
|
||||
// create constraints on moderator
|
||||
await db.ExecuteSqlCommandAsync(@"CREATE TABLE `temp_new_moderator` (
|
||||
await db.ExecuteSqlRawAsync(@"CREATE TABLE `temp_new_moderator` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`discord_id` INTEGER NOT NULL,
|
||||
`sudoer` INTEGER NOT NULL
|
||||
)", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("INSERT INTO temp_new_moderator SELECT `id`,`discord_id`,`sudoer` FROM `moderator`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("DROP TABLE `moderator`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("ALTER TABLE `temp_new_moderator` RENAME TO `moderator`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("CREATE UNIQUE INDEX `moderator_discord_id` ON `moderator` (`discord_id`)", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("INSERT INTO temp_new_moderator SELECT `id`,`discord_id`,`sudoer` FROM `moderator`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("DROP TABLE `moderator`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("ALTER TABLE `temp_new_moderator` RENAME TO `moderator`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("CREATE UNIQUE INDEX `moderator_discord_id` ON `moderator` (`discord_id`)", cancellationToken);
|
||||
// create constraints on piracystring
|
||||
await db.ExecuteSqlCommandAsync(@"CREATE TABLE `temp_new_piracystring` (
|
||||
await db.ExecuteSqlRawAsync(@"CREATE TABLE `temp_new_piracystring` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`string` varchar ( 255 ) NOT NULL
|
||||
)", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("INSERT INTO temp_new_piracystring SELECT `id`,`string` FROM `piracystring`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("DROP TABLE `piracystring`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("ALTER TABLE `temp_new_piracystring` RENAME TO `piracystring`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("CREATE UNIQUE INDEX `piracystring_string` ON `piracystring` (`string`)", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("INSERT INTO temp_new_piracystring SELECT `id`,`string` FROM `piracystring`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("DROP TABLE `piracystring`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("ALTER TABLE `temp_new_piracystring` RENAME TO `piracystring`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("CREATE UNIQUE INDEX `piracystring_string` ON `piracystring` (`string`)", cancellationToken);
|
||||
// create constraints on warning
|
||||
await db.ExecuteSqlCommandAsync(@"CREATE TABLE `temp_new_warning` (
|
||||
await db.ExecuteSqlRawAsync(@"CREATE TABLE `temp_new_warning` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`discord_id` INTEGER NOT NULL,
|
||||
`reason` TEXT NOT NULL,
|
||||
`full_reason` TEXT NOT NULL,
|
||||
`issuer_id` INTEGER NOT NULL DEFAULT 0
|
||||
)", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("INSERT INTO temp_new_warning SELECT `id`,`discord_id`,`reason`,`full_reason`,`issuer_id` FROM `warning`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("DROP TABLE `warning`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("ALTER TABLE `temp_new_warning` RENAME TO `warning`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("CREATE INDEX `warning_discord_id` ON `warning` (`discord_id`)", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("INSERT INTO temp_new_warning SELECT `id`,`discord_id`,`reason`,`full_reason`,`issuer_id` FROM `warning`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("DROP TABLE `warning`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("ALTER TABLE `temp_new_warning` RENAME TO `warning`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("CREATE INDEX `warning_discord_id` ON `warning` (`discord_id`)", cancellationToken);
|
||||
// create constraints on explanation
|
||||
await db.ExecuteSqlCommandAsync(@"CREATE TABLE `temp_new_explanation` (
|
||||
await db.ExecuteSqlRawAsync(@"CREATE TABLE `temp_new_explanation` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`keyword` TEXT NOT NULL,
|
||||
`text` TEXT NOT NULL
|
||||
)", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("INSERT INTO temp_new_explanation SELECT `id`,`keyword`,`text` FROM `explanation`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("DROP TABLE `explanation`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("ALTER TABLE `temp_new_explanation` RENAME TO `explanation`", cancellationToken);
|
||||
await db.ExecuteSqlCommandAsync("CREATE UNIQUE INDEX `explanation_keyword` ON `explanation` (`keyword`)", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("INSERT INTO temp_new_explanation SELECT `id`,`keyword`,`text` FROM `explanation`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("DROP TABLE `explanation`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("ALTER TABLE `temp_new_explanation` RENAME TO `explanation`", cancellationToken);
|
||||
await db.ExecuteSqlRawAsync("CREATE UNIQUE INDEX `explanation_keyword` ON `explanation` (`keyword`)", cancellationToken);
|
||||
tx.Commit();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CompatApiClient.Utils;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
|
||||
namespace CompatBot.Utils
|
||||
{
|
||||
@@ -128,7 +126,7 @@ namespace CompatBot.Utils
|
||||
width[i] = Math.Min(width[i], maxWidth[i]);
|
||||
|
||||
var result = new StringBuilder().AppendLine("```");
|
||||
var firstIdx = disabled.IndexOf(false);
|
||||
var firstIdx = Array.IndexOf(disabled, false);
|
||||
if (firstIdx < 0)
|
||||
throw new InvalidOperationException("Can't format table as every column is disabled");
|
||||
|
||||
|
||||
@@ -414,9 +414,9 @@ namespace CompatBot.Utils.ResultFormatters
|
||||
}
|
||||
|
||||
if (result.EndsWith(".0.0"))
|
||||
result = result.Substring(0, result.Length - 4);
|
||||
if (result.Length > 3 && result[result.Length - 2] == '.')
|
||||
result = result.Substring(0, result.Length - 1) + "0" + result[result.Length - 1];
|
||||
result = result[..^4];
|
||||
if (result.Length > 3 && result[^2] == '.')
|
||||
result = result[..^1] + "0" + result[^1];
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user