From 7abdfe27cbb8e411df3f80cad74e5c9781a1bd73 Mon Sep 17 00:00:00 2001 From: gamer147 Date: Tue, 26 May 2026 23:01:26 -0400 Subject: [PATCH] review(bp): drop fragile cast, thread CT, internalize cache reset - IndexResponse.BattlePassLevelInfo widened to IReadOnlyDictionary? so any IReadOnlyDictionary impl (FrozenDictionary, wrapper, etc.) serializes correctly instead of silently null-ing via a failed as-cast - LoadController.Index now takes CancellationToken ct and threads it to GetLevelCurveAsync instead of CancellationToken.None - BattlePassRepository.ResetLevelCurveCache changed from public to internal; added InternalsVisibleTo("SVSim.UnitTests") to SVSim.Database.csproj (was absent) --- .../Repositories/BattlePass/BattlePassRepository.cs | 2 +- SVSim.Database/SVSim.Database.csproj | 4 ++++ SVSim.EmulatedEntrypoint/Controllers/LoadController.cs | 5 ++--- .../Models/Dtos/Responses/IndexResponse.cs | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/SVSim.Database/Repositories/BattlePass/BattlePassRepository.cs b/SVSim.Database/Repositories/BattlePass/BattlePassRepository.cs index d2f1899..4cf1638 100644 --- a/SVSim.Database/Repositories/BattlePass/BattlePassRepository.cs +++ b/SVSim.Database/Repositories/BattlePass/BattlePassRepository.cs @@ -56,5 +56,5 @@ public sealed class BattlePassRepository : IBattlePassRepository /// cache has already been populated (by an earlier test's HTTP call) must call this before /// re-seeding so the next read fetches fresh rows. /// - public static void ResetLevelCurveCache() => _curveCache = null; + internal static void ResetLevelCurveCache() => _curveCache = null; } diff --git a/SVSim.Database/SVSim.Database.csproj b/SVSim.Database/SVSim.Database.csproj index 59ff261..1441b8c 100644 --- a/SVSim.Database/SVSim.Database.csproj +++ b/SVSim.Database/SVSim.Database.csproj @@ -6,6 +6,10 @@ enable + + + + diff --git a/SVSim.EmulatedEntrypoint/Controllers/LoadController.cs b/SVSim.EmulatedEntrypoint/Controllers/LoadController.cs index fbc94ba..0502b3a 100644 --- a/SVSim.EmulatedEntrypoint/Controllers/LoadController.cs +++ b/SVSim.EmulatedEntrypoint/Controllers/LoadController.cs @@ -63,7 +63,7 @@ public class LoadController : SVSimController } [HttpPost("index")] - public async Task> Index(IndexRequest request) + public async Task> Index(IndexRequest request, CancellationToken ct) { var shortUdidClaim = User.Claims.FirstOrDefault(c => c.Type == ShadowverseClaimTypes.ShortUdidClaim)?.Value; if (shortUdidClaim is null || !long.TryParse(shortUdidClaim, out long shortUdid)) @@ -197,8 +197,7 @@ public class LoadController : SVSimController LootBoxRegulations = new LootBoxRegulations(), GatheringInfo = new GatheringInfo(), IsBattlePassPeriod = rotation.IsBattlePassPeriod, - BattlePassLevelInfo = (await _battlePass.GetLevelCurveAsync(CancellationToken.None)) - as Dictionary, + BattlePassLevelInfo = await _battlePass.GetLevelCurveAsync(ct), SpecialCrystalInfos = new List(), AvatarRotationInfo = await BuildAvatarInfoAsync(), MyRotationInfo = await BuildMyRotationInfoAsync(), diff --git a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/IndexResponse.cs b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/IndexResponse.cs index f251b59..5d2e57c 100644 --- a/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/IndexResponse.cs +++ b/SVSim.EmulatedEntrypoint/Models/Dtos/Responses/IndexResponse.cs @@ -243,7 +243,7 @@ public class IndexResponse /// [JsonPropertyName("battle_pass_level_info")] [Key("battle_pass_level_info")] - public Dictionary? BattlePassLevelInfo { get; set; } + public IReadOnlyDictionary? BattlePassLevelInfo { get; set; } /// /// Wire is string[]; parser calls .ToString() on each element (LoadDetail.cs:493-499).