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"];
|
var schemaVersionNode = rootObj["schemaVersion"];
|
||||||
if (schemaVersionNode is not JsonValue schemaVersionValue ||
|
if (schemaVersionNode is not JsonValue schemaVersionValue ||
|
||||||
schemaVersionValue.TryGetValue<int>(out var schemaVersion) == false ||
|
!schemaVersionValue.TryGetValue<int>(out var schemaVersion) ||
|
||||||
schemaVersion != 1)
|
schemaVersion != 1)
|
||||||
{
|
{
|
||||||
var got = schemaVersionNode?.ToJsonString() ?? "null";
|
var got = schemaVersionNode?.ToJsonString() ?? "null";
|
||||||
|
|
@ -122,7 +122,9 @@ public static class ItemDefinitionCatalogLoader
|
||||||
|
|
||||||
if (rowObj["stackMax"] is JsonValue stackMaxValue &&
|
if (rowObj["stackMax"] is JsonValue stackMaxValue &&
|
||||||
stackMaxValue.TryGetValue<int>(out var stackMax))
|
stackMaxValue.TryGetValue<int>(out var stackMax))
|
||||||
|
{
|
||||||
idToStackMax[iid] = stackMax;
|
idToStackMax[iid] = stackMax;
|
||||||
|
}
|
||||||
|
|
||||||
rows[iid] = ParseRow(rowObj);
|
rows[iid] = ParseRow(rowObj);
|
||||||
}
|
}
|
||||||
|
|
@ -142,11 +144,14 @@ public static class ItemDefinitionCatalogLoader
|
||||||
ThrowIfAny(errors);
|
ThrowIfAny(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LogInformation(
|
if (logger.IsEnabled(LogLevel.Information))
|
||||||
"Loaded item catalog from {ItemsDirectory}: {ItemCount} item(s) across {CatalogFileCount} JSON catalog file(s).",
|
{
|
||||||
itemsDirectory,
|
logger.LogInformation(
|
||||||
rows.Count,
|
"Loaded item catalog from {ItemsDirectory}: {ItemCount} item(s) across {CatalogFileCount} JSON catalog file(s).",
|
||||||
jsonFiles.Length);
|
itemsDirectory,
|
||||||
|
rows.Count,
|
||||||
|
jsonFiles.Length);
|
||||||
|
}
|
||||||
|
|
||||||
return new ItemDefinitionCatalog(itemsDirectory, rows, jsonFiles.Length);
|
return new ItemDefinitionCatalog(itemsDirectory, rows, jsonFiles.Length);
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +172,9 @@ public static class ItemDefinitionCatalogLoader
|
||||||
int? durabilityMax = null;
|
int? durabilityMax = null;
|
||||||
if (rowObj["durabilityMax"] is JsonValue durabilityMaxValue &&
|
if (rowObj["durabilityMax"] is JsonValue durabilityMaxValue &&
|
||||||
durabilityMaxValue.TryGetValue<int>(out var dmax))
|
durabilityMaxValue.TryGetValue<int>(out var dmax))
|
||||||
|
{
|
||||||
durabilityMax = dmax;
|
durabilityMax = dmax;
|
||||||
|
}
|
||||||
|
|
||||||
return new ItemDefRow(id, displayName, prototypeRole, stackMax, inventorySlotKind, rarity, bindPolicy, durabilityMax);
|
return new ItemDefRow(id, displayName, prototypeRole, stackMax, inventorySlotKind, rarity, bindPolicy, durabilityMax);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue