NEO-51: Guard item catalog startup log for CA1873.

Skip LogInformation argument evaluation when Information is disabled.
pull/86/head
VinPropane 2026-05-17 22:00:27 -04:00
parent 0a3c28ae5c
commit c2366eed4c
1 changed files with 13 additions and 6 deletions

View File

@ -65,7 +65,7 @@ public static class ItemDefinitionCatalogLoader
var schemaVersionNode = rootObj["schemaVersion"];
if (schemaVersionNode is not JsonValue schemaVersionValue ||
schemaVersionValue.TryGetValue<int>(out var schemaVersion) == false ||
!schemaVersionValue.TryGetValue<int>(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<int>(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<int>(out var dmax))
{
durabilityMax = dmax;
}
return new ItemDefRow(id, displayName, prototypeRole, stackMax, inventorySlotKind, rarity, bindPolicy, durabilityMax);
}