mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Lint for prototype IDs with spaces (#6087)
* feat: lint for prototype IDs with spaces * feat: also disallow periods * Update RELEASE-NOTES.md --------- Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -36,6 +36,7 @@ END TEMPLATE-->
|
||||
### Breaking changes
|
||||
|
||||
* More members in `IntegrationInstance` now enforce that the instance is idle before accessing it.
|
||||
* `Prototype.ValidateDirectory` now requires that prototype IDs have no spaces or periods in them.
|
||||
* `IPrototypeManager.TryIndex` no longer logs errors unless using the overload with an optional parameter. Use `Resolve()` instead if error logging is desired.
|
||||
|
||||
### New features
|
||||
|
||||
@@ -13,6 +13,11 @@ namespace Robust.Shared.Prototypes;
|
||||
|
||||
public partial class PrototypeManager
|
||||
{
|
||||
// Characters that we don't allow in prototype IDs. Spaces and periods both
|
||||
// break generated localization strings for entity prototypes, so we just
|
||||
// disallow them for all prototypes.
|
||||
private static readonly char[] DisallowedIdChars = [' ', '.'];
|
||||
|
||||
public Dictionary<string, HashSet<ErrorNode>> ValidateDirectory(ResPath path) => ValidateDirectory(path, out _);
|
||||
|
||||
public Dictionary<string, HashSet<ErrorNode>> ValidateDirectory(ResPath path,
|
||||
@@ -56,6 +61,13 @@ public partial class PrototypeManager
|
||||
var data = new PrototypeValidationData(id, mapping, resourcePath.ToString());
|
||||
mapping.Remove("type");
|
||||
|
||||
if (DisallowedIdChars.TryFirstOrNull(c => id.Contains(c), out var letter))
|
||||
{
|
||||
dict.GetOrNew(data.File)
|
||||
.Add(new ErrorNode(mapping, $"Prototype '{id}' ({type}) contains disallowed "
|
||||
+ $"character '{letter}'."));
|
||||
}
|
||||
|
||||
if (prototypes.GetOrNew(type).TryAdd(id, data))
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user