From b0d9763beaeb8a235f112389a9b0deedc689898e Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Wed, 27 Mar 2024 10:56:33 +0200 Subject: [PATCH] Update --- .../BUTR.Site.NexusMods.Client.csproj | 28 +++++++++---------- .../Models/DemoUser.cs | 2 +- ...NexusMods.Server.ValueObjects.Vogen.csproj | 2 +- .../BUTR.Site.NexusMods.Server.csproj | 23 ++++++++------- .../CrashReportsAnalyzerController.cs | 10 +++---- .../RecreateStacktraceController.cs | 4 +-- .../Extensions/ListExtensions.cs | 2 +- src/BUTR.Site.NexusMods.Server/Program.cs | 9 ++---- .../Properties/launchSettings.json | 4 ++- .../General/ICrashReportBatchedHandler.cs | 4 +-- .../HttpClients/ICrashReporterClient.cs | 4 +-- .../{DiscordRoles.cs => DiscordConstants.cs} | 0 12 files changed, 45 insertions(+), 47 deletions(-) rename src/BUTR.Site.NexusMods.Shared/Helpers/{DiscordRoles.cs => DiscordConstants.cs} (100%) diff --git a/src/BUTR.Site.NexusMods.Client/BUTR.Site.NexusMods.Client.csproj b/src/BUTR.Site.NexusMods.Client/BUTR.Site.NexusMods.Client.csproj index e1b383d0..07e7210c 100644 --- a/src/BUTR.Site.NexusMods.Client/BUTR.Site.NexusMods.Client.csproj +++ b/src/BUTR.Site.NexusMods.Client/BUTR.Site.NexusMods.Client.csproj @@ -17,21 +17,21 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - + + diff --git a/src/BUTR.Site.NexusMods.Client/Models/DemoUser.cs b/src/BUTR.Site.NexusMods.Client/Models/DemoUser.cs index 9ebe6fa1..41c3711b 100644 --- a/src/BUTR.Site.NexusMods.Client/Models/DemoUser.cs +++ b/src/BUTR.Site.NexusMods.Client/Models/DemoUser.cs @@ -73,7 +73,7 @@ static string GetException(ExceptionModel? exception, bool inner = false) => exc var report = new CrashReportModel2( id: cr.Id, version: cr.Version, - gameVersion: cr.GameVersion, + gameVersion: cr.Metadata.GameVersion, exceptionType: cr.Exception.Type, exception: GetException(cr.Exception), date: DateTimeOffset.UtcNow, diff --git a/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/BUTR.Site.NexusMods.Server.ValueObjects.Vogen.csproj b/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/BUTR.Site.NexusMods.Server.ValueObjects.Vogen.csproj index a7d4faec..9fc9fcde 100644 --- a/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/BUTR.Site.NexusMods.Server.ValueObjects.Vogen.csproj +++ b/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/BUTR.Site.NexusMods.Server.ValueObjects.Vogen.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj b/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj index 99c37fe2..afc58cd3 100644 --- a/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj +++ b/src/BUTR.Site.NexusMods.Server/BUTR.Site.NexusMods.Server.csproj @@ -16,28 +16,28 @@ - + - - + + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + - - + + @@ -46,7 +46,7 @@ - + @@ -56,11 +56,10 @@ - - + diff --git a/src/BUTR.Site.NexusMods.Server/Controllers/CrashReportsAnalyzerController.cs b/src/BUTR.Site.NexusMods.Server/Controllers/CrashReportsAnalyzerController.cs index 946de0eb..ccc00ed8 100644 --- a/src/BUTR.Site.NexusMods.Server/Controllers/CrashReportsAnalyzerController.cs +++ b/src/BUTR.Site.NexusMods.Server/Controllers/CrashReportsAnalyzerController.cs @@ -91,7 +91,7 @@ static bool GetTypeLoadExceptionLevel(ExceptionModel? exceptionModel, ref int le var involvedModule = crashReport.InvolvedModules[level]; yield return new ModuleSuggestedFix { - ModuleId = involvedModule.ModuleId, + ModuleId = involvedModule.ModuleOrLoaderPluginId, Type = ModuleSuggestedFixType.Update, }; } @@ -106,9 +106,9 @@ private async IAsyncEnumerable GetModuleUpdatesForBannerlordAsync( { await Task.Yield(); - if (!ApplicationVersion.TryParse(crashReport.GameVersion, out var gVersion)) yield break; + if (!ApplicationVersion.TryParse(crashReport.Metadata.GameVersion, out var gVersion)) yield break; - var moduleIds = crashReport.Modules.Where(x => !x.IsOfficial && string.IsNullOrEmpty(x.Url) && string.IsNullOrEmpty(x.UpdateInfo)) + var moduleIds = crashReport.Modules.Where(x => !x.IsOfficial && string.IsNullOrEmpty(x.Url) && x.UpdateInfo is null) .Select(x => ModuleId.From(x.Id)).ToArray(); var nexusModsIds = crashReport.Modules.Where(x => !x.IsOfficial && !string.IsNullOrEmpty(x.Url)) .Select(x => NexusModsModId.TryParseUrl(x.Url, out var modId) ? modId : NexusModsModId.None) @@ -116,7 +116,7 @@ private async IAsyncEnumerable GetModuleUpdatesForBannerlordAsync( var nexusModsIds2 = crashReport.Modules.Where(x => !x.IsOfficial && !string.IsNullOrEmpty(x.Url)) .Select(x => new { ModuelId = ModuleId.From(x.Id), NexusModsId = NexusModsModId.From(NexusModsUtils.TryParse(x.Url, out _, out var id) ? (int) id : -1) }) .Where(x => x.NexusModsId != NexusModsModId.None).ToArray(); - var updateInfos = crashReport.Modules.Where(x => !x.IsOfficial && !string.IsNullOrEmpty(x.UpdateInfo)) + var updateInfos = crashReport.Modules.Where(x => !x.IsOfficial && x.UpdateInfo is not null) .Select(x => new { ModuleId = ModuleId.From(x.Id), x.UpdateInfo }).ToArray(); var moduleIdVersions = crashReport.Modules .Where(x => !x.IsOfficial).Select(x => new { ModuleId = ModuleId.From(x.Id), Version = ModuleVersion.From(x.Version) }).ToArray(); @@ -166,7 +166,7 @@ private async IAsyncEnumerable GetModuleUpdatesForBannerlordAsync( { ModuleId = x.ModuleId.Value, ModuleVersion = x.ModuleVersion.ToString(), - IsModuleInvolved = crashReport.InvolvedModules.Any(y => y.ModuleId == x.ModuleId) + IsModuleInvolved = crashReport.InvolvedModules.Any(y => y.ModuleOrLoaderPluginId == x.ModuleId) }; } } diff --git a/src/BUTR.Site.NexusMods.Server/Controllers/RecreateStacktraceController.cs b/src/BUTR.Site.NexusMods.Server/Controllers/RecreateStacktraceController.cs index 58c50c05..530d97d8 100644 --- a/src/BUTR.Site.NexusMods.Server/Controllers/RecreateStacktraceController.cs +++ b/src/BUTR.Site.NexusMods.Server/Controllers/RecreateStacktraceController.cs @@ -56,7 +56,7 @@ public RecreateStacktraceController(ILogger logger if (!CrashReportParser.TryParse(crashReportContent, out var version, out var crashReport, out var json)) return ApiBadRequest("Invalid crash report!"); - var gameVersion = crashReport.GameVersion; + var gameVersion = crashReport.Metadata.GameVersion; var assemblyFiles = await _steamBinaryCache.GetBranchAssemblyFilesAsync(gameVersion, ct); var recreatedStacktrace = RecreateStacktraceUtils.GetRecreatedStacktraceUnordered(assemblyFiles, crashReport, ct).ToList(); @@ -93,7 +93,7 @@ public async Task> HtmlAsync(CrashReportFileId id, Cancella if (!CrashReportParser.TryParse(crashReportContent, out var version, out var crashReport, out var json)) return BadRequest(); - var gameVersion = crashReport.GameVersion; + var gameVersion = crashReport.Metadata.GameVersion; var assemblyFiles = await _steamBinaryCache.GetBranchAssemblyFilesAsync(gameVersion, ct); var recreatedStacktrace = RecreateStacktraceUtils.GetRecreatedStacktraceUnordered(assemblyFiles, crashReport, ct).ToList(); diff --git a/src/BUTR.Site.NexusMods.Server/Extensions/ListExtensions.cs b/src/BUTR.Site.NexusMods.Server/Extensions/ListExtensions.cs index 6ade06da..92085b87 100644 --- a/src/BUTR.Site.NexusMods.Server/Extensions/ListExtensions.cs +++ b/src/BUTR.Site.NexusMods.Server/Extensions/ListExtensions.cs @@ -16,7 +16,7 @@ public static class ListExtensions /// The list to search. /// The key to search for. /// A function to extract a key from an element. - /// The zero-based index of item in the sorted List, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of Count. + /// The zero-based index of item in the sorted List{T}, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of Count. public static int BinarySearch(this IList instance, TKey itemKey, Func keySelector) where TKey : IComparable, IComparable { diff --git a/src/BUTR.Site.NexusMods.Server/Program.cs b/src/BUTR.Site.NexusMods.Server/Program.cs index f017b4d6..042fc659 100644 --- a/src/BUTR.Site.NexusMods.Server/Program.cs +++ b/src/BUTR.Site.NexusMods.Server/Program.cs @@ -85,8 +85,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host options.WaitForJobsToComplete = true; }); - var oltpSection = ctx.Configuration.GetSection("Oltp"); - if (oltpSection != null!) + if (ctx.Configuration.GetSection("Oltp") is { } oltpSection) { var openTelemetry = services.AddOpenTelemetry() .ConfigureResource(builder => @@ -101,8 +100,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host builder.AddTelemetrySdk(); }); - var metricsEndpoint = oltpSection.GetValue("MetricsEndpoint"); - if (metricsEndpoint is not null) + if (oltpSection.GetValue("MetricsEndpoint") is { } metricsEndpoint) { var metricsProtocol = oltpSection.GetValue("MetricsProtocol"); openTelemetry.WithMetrics(builder => builder @@ -120,8 +118,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host })); } - var tracingEndpoint = oltpSection.GetValue("TracingEndpoint"); - if (tracingEndpoint is not null) + if (oltpSection.GetValue("TracingEndpoint") is { } tracingEndpoint) { var tracingProtocol = oltpSection.GetValue("TracingProtocol"); openTelemetry.WithTracing(builder => builder diff --git a/src/BUTR.Site.NexusMods.Server/Properties/launchSettings.json b/src/BUTR.Site.NexusMods.Server/Properties/launchSettings.json index a30851fa..8d96db27 100644 --- a/src/BUTR.Site.NexusMods.Server/Properties/launchSettings.json +++ b/src/BUTR.Site.NexusMods.Server/Properties/launchSettings.json @@ -4,7 +4,9 @@ "commandName": "Project", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "launchBrowser": false, + "launchUrl": "swagger" } } } diff --git a/src/BUTR.Site.NexusMods.Server/Services/General/ICrashReportBatchedHandler.cs b/src/BUTR.Site.NexusMods.Server/Services/General/ICrashReportBatchedHandler.cs index a2419541..cd910a94 100644 --- a/src/BUTR.Site.NexusMods.Server/Services/General/ICrashReportBatchedHandler.cs +++ b/src/BUTR.Site.NexusMods.Server/Services/General/ICrashReportBatchedHandler.cs @@ -254,7 +254,7 @@ private async Task WriteCrashReportsToDatabaseAsync(CancellationToken ct) CrashReportId = crashReportId, Url = CrashReportUrl.From(new Uri(new Uri(_options.Endpoint), fileId.ToString())), Version = CrashReportVersion.From(report.Version), - GameVersion = GameVersion.From(report.GameVersion), + GameVersion = GameVersion.From(report.Metadata.GameVersion), ExceptionType = entityFactory.GetOrCreateExceptionType(ExceptionTypeId.From(report.Exception.Type)), Exception = GetException(report.Exception), CreatedAt = fileId.Value.Length == 8 ? DateTimeOffset.UnixEpoch.ToUniversalTime() : date.ToUniversalTime(), @@ -277,7 +277,7 @@ private async Task WriteCrashReportsToDatabaseAsync(CancellationToken ct) Module = entityFactory.GetOrCreateModule(ModuleId.From(x.Id)), Version = ModuleVersion.From(x.Version), NexusModsMod = NexusModsModId.TryParseUrl(x.Url, out var modId) ? entityFactory.GetOrCreateNexusModsMod(modId) : null, - IsInvolved = report.InvolvedModules.Any(y => y.ModuleId == x.Id), + IsInvolved = report.InvolvedModules.Any(y => y.ModuleOrLoaderPluginId == x.Id), })); } diff --git a/src/BUTR.Site.NexusMods.Server/Services/HttpClients/ICrashReporterClient.cs b/src/BUTR.Site.NexusMods.Server/Services/HttpClients/ICrashReporterClient.cs index 45fa38b7..0313ea3d 100644 --- a/src/BUTR.Site.NexusMods.Server/Services/HttpClients/ICrashReporterClient.cs +++ b/src/BUTR.Site.NexusMods.Server/Services/HttpClients/ICrashReporterClient.cs @@ -18,8 +18,8 @@ public interface ICrashReporterClient { Task GetCrashReportAsync(CrashReportFileId id, CancellationToken ct); Task GetCrashReportModelAsync(CrashReportFileId id, CancellationToken ct); - IAsyncEnumerable GetNewCrashReportMetadatasAsync(DateTime dateTime, [EnumeratorCancellation] CancellationToken ct); - IAsyncEnumerable GetCrashReportMetadatasAsync(IEnumerable filenames, [EnumeratorCancellation] CancellationToken ct); + IAsyncEnumerable GetNewCrashReportMetadatasAsync(DateTime dateTime, CancellationToken ct); + IAsyncEnumerable GetCrashReportMetadatasAsync(IEnumerable filenames, CancellationToken ct); } public sealed class CrashReporterClient : ICrashReporterClient diff --git a/src/BUTR.Site.NexusMods.Shared/Helpers/DiscordRoles.cs b/src/BUTR.Site.NexusMods.Shared/Helpers/DiscordConstants.cs similarity index 100% rename from src/BUTR.Site.NexusMods.Shared/Helpers/DiscordRoles.cs rename to src/BUTR.Site.NexusMods.Shared/Helpers/DiscordConstants.cs