NEO-51: Guard item catalog startup log for CA1873.
Skip LogInformation argument evaluation when Information is disabled.pull/86/head
parent
0a3c28ae5c
commit
c2366eed4c
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue