From c2366eed4c38abeace6ee773d1f52431b6e89655 Mon Sep 17 00:00:00 2001 From: VinPropane Date: Sun, 17 May 2026 22:00:27 -0400 Subject: [PATCH] NEO-51: Guard item catalog startup log for CA1873. Skip LogInformation argument evaluation when Information is disabled. --- .../Game/Items/ItemDefinitionCatalogLoader.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/server/NeonSprawl.Server/Game/Items/ItemDefinitionCatalogLoader.cs b/server/NeonSprawl.Server/Game/Items/ItemDefinitionCatalogLoader.cs index 4f3cf3f..2edce09 100644 --- a/server/NeonSprawl.Server/Game/Items/ItemDefinitionCatalogLoader.cs +++ b/server/NeonSprawl.Server/Game/Items/ItemDefinitionCatalogLoader.cs @@ -65,7 +65,7 @@ public static class ItemDefinitionCatalogLoader var schemaVersionNode = rootObj["schemaVersion"]; if (schemaVersionNode is not JsonValue schemaVersionValue || - schemaVersionValue.TryGetValue(out var schemaVersion) == false || + !schemaVersionValue.TryGetValue(out var schemaVersion) || schemaVersion != 1) { var got = schemaVersionNode?.ToJsonString() ?? "null"; @@ -122,7 +122,9 @@ public static class ItemDefinitionCatalogLoader if (rowObj["stackMax"] is JsonValue stackMaxValue && stackMaxValue.TryGetValue(out var stackMax)) + { idToStackMax[iid] = stackMax; + } rows[iid] = ParseRow(rowObj); } @@ -142,11 +144,14 @@ public static class ItemDefinitionCatalogLoader ThrowIfAny(errors); } - logger.LogInformation( - "Loaded item catalog from {ItemsDirectory}: {ItemCount} item(s) across {CatalogFileCount} JSON catalog file(s).", - itemsDirectory, - rows.Count, - jsonFiles.Length); + if (logger.IsEnabled(LogLevel.Information)) + { + logger.LogInformation( + "Loaded item catalog from {ItemsDirectory}: {ItemCount} item(s) across {CatalogFileCount} JSON catalog file(s).", + itemsDirectory, + rows.Count, + jsonFiles.Length); + } return new ItemDefinitionCatalog(itemsDirectory, rows, jsonFiles.Length); } @@ -167,7 +172,9 @@ public static class ItemDefinitionCatalogLoader int? durabilityMax = null; if (rowObj["durabilityMax"] is JsonValue durabilityMaxValue && durabilityMaxValue.TryGetValue(out var dmax)) + { durabilityMax = dmax; + } return new ItemDefRow(id, displayName, prototypeRole, stackMax, inventorySlotKind, rarity, bindPolicy, durabilityMax); }