Rename Fluent-related code to be more precise.

This commit is contained in:
Paul Chote
2024-10-01 19:34:12 +01:00
committed by Gustas
parent 771b9ddfda
commit b29b685058
176 changed files with 1349 additions and 1369 deletions

View File

@@ -27,23 +27,23 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Lint
{
sealed class CheckTranslationReference : ILintPass, ILintMapPass
sealed class CheckFluentReferences : ILintPass, ILintMapPass
{
static readonly Regex TranslationFilenameRegex = new(@"(?<language>[^\/\\]+)\.ftl$");
static readonly Regex FilenameRegex = new(@"(?<language>[^\/\\]+)\.ftl$");
void ILintMapPass.Run(Action<string> emitError, Action<string> emitWarning, ModData modData, Map map)
{
if (map.TranslationDefinitions == null)
return;
var usedKeys = GetUsedTranslationKeysInMap(map, emitWarning);
var usedKeys = GetUsedFluentKeysInMap(map, emitWarning);
foreach (var context in usedKeys.EmptyKeyContexts)
emitWarning($"Empty key in map translation files required by {context}");
emitWarning($"Empty key in map ftl files required by {context}");
var mapTranslations = FieldLoader.GetValue<string[]>("value", map.TranslationDefinitions.Value);
foreach (var language in GetTranslationLanguages(modData))
foreach (var language in GetModLanguages(modData))
{
// Check keys and variables are not missing across all language files.
// But for maps we don't warn on unused keys. They might be unused on *this* map,
@@ -52,20 +52,20 @@ namespace OpenRA.Mods.Common.Lint
modData.Manifest.Translations.Concat(mapTranslations), map.Open, usedKeys,
language, _ => false, emitError, emitWarning);
var modTranslation = new Translation(language, modData.Manifest.Translations, modData.DefaultFileSystem, _ => { });
var mapTranslation = new Translation(language, mapTranslations, map, error => emitError(error.Message));
var modFluentBundle = new FluentBundle(language, modData.Manifest.Translations, modData.DefaultFileSystem, _ => { });
var mapFluentBundle = new FluentBundle(language, mapTranslations, map, error => emitError(error.Message));
foreach (var group in usedKeys.KeysWithContext)
{
if (modTranslation.HasMessage(group.Key))
if (modFluentBundle.HasMessage(group.Key))
{
if (mapTranslation.HasMessage(group.Key))
emitWarning($"Key `{group.Key}` in `{language}` language in map translation files already exists in mod translations and will not be used.");
if (mapFluentBundle.HasMessage(group.Key))
emitWarning($"Key `{group.Key}` in `{language}` language in map ftl files already exists in mod translations and will not be used.");
}
else if (!mapTranslation.HasMessage(group.Key))
else if (!mapFluentBundle.HasMessage(group.Key))
{
foreach (var context in group)
emitWarning($"Missing key `{group.Key}` in `{language}` language in map translation files required by {context}");
emitWarning($"Missing key `{group.Key}` in `{language}` language in map ftl files required by {context}");
}
}
}
@@ -73,15 +73,14 @@ namespace OpenRA.Mods.Common.Lint
void ILintPass.Run(Action<string> emitError, Action<string> emitWarning, ModData modData)
{
var (usedKeys, testedFields) = GetUsedTranslationKeysInMod(modData);
var (usedKeys, testedFields) = GetUsedFluentKeysInMod(modData);
foreach (var context in usedKeys.EmptyKeyContexts)
emitWarning($"Empty key in mod translation files required by {context}");
foreach (var language in GetTranslationLanguages(modData))
foreach (var language in GetModLanguages(modData))
{
Console.WriteLine($"Testing translation: {language}");
var translation = new Translation(language, modData.Manifest.Translations, modData.DefaultFileSystem, error => emitError(error.Message));
Console.WriteLine($"Testing language: {language}");
CheckModWidgets(modData, usedKeys, testedFields);
// With the fully populated keys, check keys and variables are not missing and not unused across all language files.
@@ -99,32 +98,32 @@ namespace OpenRA.Mods.Common.Lint
continue;
foreach (var context in group)
emitWarning($"Missing key `{group.Key}` in `{language}` language in mod translation files required by {context}");
emitWarning($"Missing key `{group.Key}` in `{language}` language in mod ftl files required by {context}");
}
}
// Check if we couldn't test any fields.
const BindingFlags Binding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
var allTranslatableFields = modData.ObjectCreator.GetTypes().SelectMany(t =>
t.GetFields(Binding).Where(m => Utility.HasAttribute<TranslationReferenceAttribute>(m))).ToArray();
var untestedFields = allTranslatableFields.Except(testedFields);
var allFluentFields = modData.ObjectCreator.GetTypes().SelectMany(t =>
t.GetFields(Binding).Where(m => Utility.HasAttribute<FluentReferenceAttribute>(m))).ToArray();
var untestedFields = allFluentFields.Except(testedFields);
foreach (var field in untestedFields)
emitError(
$"Lint pass ({nameof(CheckTranslationReference)}) lacks the know-how to test translatable field " +
$"Lint pass ({nameof(CheckFluentReferences)}) lacks the know-how to test translatable field " +
$"`{field.ReflectedType.Name}.{field.Name}` - previous warnings may be incorrect");
}
static IEnumerable<string> GetTranslationLanguages(ModData modData)
static IEnumerable<string> GetModLanguages(ModData modData)
{
return modData.Manifest.Translations
.Select(filename => TranslationFilenameRegex.Match(filename).Groups["language"].Value)
.Select(filename => FilenameRegex.Match(filename).Groups["language"].Value)
.Distinct()
.OrderBy(l => l);
}
static TranslationKeys GetUsedTranslationKeysInRuleset(Ruleset rules)
static Keys GetUsedFluentKeysInRuleset(Ruleset rules)
{
var usedKeys = new TranslationKeys();
var usedKeys = new Keys();
foreach (var actorInfo in rules.Actors)
{
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
@@ -132,12 +131,12 @@ namespace OpenRA.Mods.Common.Lint
var traitType = traitInfo.GetType();
foreach (var field in Utility.GetFields(traitType))
{
var translationReference = Utility.GetCustomAttributes<TranslationReferenceAttribute>(field, true).SingleOrDefault();
if (translationReference == null)
var fluentReference = Utility.GetCustomAttributes<FluentReferenceAttribute>(field, true).SingleOrDefault();
if (fluentReference == null)
continue;
foreach (var key in LintExts.GetFieldValues(traitInfo, field, translationReference.DictionaryReference))
usedKeys.Add(key, translationReference, $"Actor `{actorInfo.Key}` trait `{traitType.Name[..^4]}.{field.Name}`");
foreach (var key in LintExts.GetFieldValues(traitInfo, field, fluentReference.DictionaryReference))
usedKeys.Add(key, fluentReference, $"Actor `{actorInfo.Key}` trait `{traitType.Name[..^4]}.{field.Name}`");
}
}
}
@@ -149,12 +148,12 @@ namespace OpenRA.Mods.Common.Lint
var warheadType = warhead.GetType();
foreach (var field in Utility.GetFields(warheadType))
{
var translationReference = Utility.GetCustomAttributes<TranslationReferenceAttribute>(field, true).SingleOrDefault();
if (translationReference == null)
var fluentReference = Utility.GetCustomAttributes<FluentReferenceAttribute>(field, true).SingleOrDefault();
if (fluentReference == null)
continue;
foreach (var key in LintExts.GetFieldValues(warhead, field, translationReference.DictionaryReference))
usedKeys.Add(key, translationReference, $"Weapon `{weapon.Key}` warhead `{warheadType.Name[..^7]}.{field.Name}`");
foreach (var key in LintExts.GetFieldValues(warhead, field, fluentReference.DictionaryReference))
usedKeys.Add(key, fluentReference, $"Weapon `{weapon.Key}` warhead `{warheadType.Name[..^7]}.{field.Name}`");
}
}
}
@@ -162,40 +161,40 @@ namespace OpenRA.Mods.Common.Lint
return usedKeys;
}
static TranslationKeys GetUsedTranslationKeysInMap(Map map, Action<string> emitWarning)
static Keys GetUsedFluentKeysInMap(Map map, Action<string> emitWarning)
{
var usedKeys = GetUsedTranslationKeysInRuleset(map.Rules);
var usedKeys = GetUsedFluentKeysInRuleset(map.Rules);
var luaScriptInfo = map.Rules.Actors[SystemActors.World].TraitInfoOrDefault<LuaScriptInfo>();
if (luaScriptInfo != null)
{
// Matches expressions such as:
// UserInterface.Translate("translation-key")
// UserInterface.Translate("translation-key\"with-escape")
// UserInterface.Translate("translation-key", { ["attribute"] = foo })
// UserInterface.Translate("translation-key", { ["attribute\"-with-escape"] = foo })
// UserInterface.Translate("translation-key", { ["attribute1"] = foo, ["attribute2"] = bar })
// UserInterface.Translate("translation-key", tableVariable)
// UserInterface.Translate("fluent-key")
// UserInterface.Translate("fluent-key\"with-escape")
// UserInterface.Translate("fluent-key", { ["attribute"] = foo })
// UserInterface.Translate("fluent-key", { ["attribute\"-with-escape"] = foo })
// UserInterface.Translate("fluent-key", { ["attribute1"] = foo, ["attribute2"] = bar })
// UserInterface.Translate("fluent-key", tableVariable)
// Extracts groups for the 'key' and each 'attr'.
// If the table isn't inline like in the last example, extracts it as 'variable'.
const string UserInterfaceTranslatePattern =
@"UserInterface\s*\.\s*Translate\s*\(" + // UserInterface.Translate(
@"\s*""(?<key>(?:[^""\\]|\\.)+?)""\s*" + // "translation-key"
@"\s*""(?<key>(?:[^""\\]|\\.)+?)""\s*" + // "fluent-key"
@"(,\s*({\s*\[\s*""(?<attr>(?:[^""\\]|\\.)*?)""\s*\]\s*=\s*.*?" + // { ["attribute1"] = foo
@"(\s*,\s*\[\s*""(?<attr>(?:[^""\\]|\\.)*?)""\s*\]\s*=\s*.*?)*\s*}\s*)" + // , ["attribute2"] = bar }
"|\\s*,\\s*(?<variable>.*?))?" + // tableVariable
@"\)"; // )
var translateRegex = new Regex(UserInterfaceTranslatePattern);
// The script in mods/common/scripts/utils.lua defines some helpers which accept a translation key
// The script in mods/common/scripts/utils.lua defines some helpers which accept a fluent key
// Matches expressions such as:
// AddPrimaryObjective(Player, "translation-key")
// AddSecondaryObjective(Player, "translation-key")
// AddPrimaryObjective(Player, "translation-key\"with-escape")
// AddPrimaryObjective(Player, "fluent-key")
// AddSecondaryObjective(Player, "fluent-key")
// AddPrimaryObjective(Player, "fluent-key\"with-escape")
// Extracts groups for the 'key'.
const string AddObjectivePattern =
@"(AddPrimaryObjective|AddSecondaryObjective)\s*\(" + // AddPrimaryObjective(
@".*?\s*,\s*""(?<key>(?:[^""\\]|\\.)+?)""\s*" + // Player, "translation-key"
@".*?\s*,\s*""(?<key>(?:[^""\\]|\\.)+?)""\s*" + // Player, "fluent-key"
@"\)"; // )
var objectiveRegex = new Regex(AddObjectivePattern);
@@ -210,7 +209,8 @@ namespace OpenRA.Mods.Common.Lint
IEnumerable<Match> matches = translateRegex.Matches(scriptText);
if (luaScriptInfo.Scripts.Contains("utils.lua"))
matches = matches.Concat(objectiveRegex.Matches(scriptText));
var scriptTranslations = matches.Select(m =>
var references = matches.Select(m =>
{
var key = m.Groups["key"].Value.Replace(@"\""", @"""");
var attrs = m.Groups["attr"].Captures.Select(c => c.Value.Replace(@"\""", @"""")).ToArray();
@@ -218,10 +218,11 @@ namespace OpenRA.Mods.Common.Lint
var line = scriptText.Take(m.Index).Count(x => x == '\n') + 1;
return (Key: key, Attrs: attrs, Variable: variable, Line: line);
}).ToArray();
foreach (var (key, attrs, variable, line) in scriptTranslations)
foreach (var (key, attrs, variable, line) in references)
{
var context = $"Script {script}:{line}";
usedKeys.Add(key, new TranslationReferenceAttribute(attrs), context);
usedKeys.Add(key, new FluentReferenceAttribute(attrs), context);
if (variable != "")
{
@@ -239,22 +240,22 @@ namespace OpenRA.Mods.Common.Lint
return usedKeys;
}
static (TranslationKeys UsedKeys, List<FieldInfo> TestedFields) GetUsedTranslationKeysInMod(ModData modData)
static (Keys UsedKeys, List<FieldInfo> TestedFields) GetUsedFluentKeysInMod(ModData modData)
{
var usedKeys = GetUsedTranslationKeysInRuleset(modData.DefaultRules);
var usedKeys = GetUsedFluentKeysInRuleset(modData.DefaultRules);
var testedFields = new List<FieldInfo>();
testedFields.AddRange(
modData.ObjectCreator.GetTypes()
.Where(t => t.IsSubclassOf(typeof(TraitInfo)) || t.IsSubclassOf(typeof(Warhead)))
.SelectMany(t => t.GetFields().Where(f => f.HasAttribute<TranslationReferenceAttribute>())));
.SelectMany(t => t.GetFields().Where(f => f.HasAttribute<FluentReferenceAttribute>())));
// HACK: Need to hardcode the custom loader for GameSpeeds.
var gameSpeeds = modData.Manifest.Get<GameSpeeds>();
var gameSpeedNameField = typeof(GameSpeed).GetField(nameof(GameSpeed.Name));
var gameSpeedTranslationReference = Utility.GetCustomAttributes<TranslationReferenceAttribute>(gameSpeedNameField, true)[0];
var gameSpeedFluentReference = Utility.GetCustomAttributes<FluentReferenceAttribute>(gameSpeedNameField, true)[0];
testedFields.Add(gameSpeedNameField);
foreach (var speed in gameSpeeds.Speeds.Values)
usedKeys.Add(speed.Name, gameSpeedTranslationReference, $"`{nameof(GameSpeed)}.{nameof(GameSpeed.Name)}`");
usedKeys.Add(speed.Name, gameSpeedFluentReference, $"`{nameof(GameSpeed)}.{nameof(GameSpeed.Name)}`");
// TODO: linter does not work with LoadUsing
foreach (var actorInfo in modData.DefaultRules.Actors)
@@ -262,12 +263,12 @@ namespace OpenRA.Mods.Common.Lint
foreach (var info in actorInfo.Value.TraitInfos<ResourceRendererInfo>())
{
var resourceTypeNameField = typeof(ResourceRendererInfo.ResourceTypeInfo).GetField(nameof(ResourceRendererInfo.ResourceTypeInfo.Name));
var resourceTypeTranslationReference = Utility.GetCustomAttributes<TranslationReferenceAttribute>(resourceTypeNameField, true)[0];
var resourceTypeFluentReference = Utility.GetCustomAttributes<FluentReferenceAttribute>(resourceTypeNameField, true)[0];
testedFields.Add(resourceTypeNameField);
foreach (var resourceTypes in info.ResourceTypes)
usedKeys.Add(
resourceTypes.Value.Name,
resourceTypeTranslationReference,
resourceTypeFluentReference,
$"`{nameof(ResourceRendererInfo.ResourceTypeInfo)}.{nameof(ResourceRendererInfo.ResourceTypeInfo.Name)}`");
}
}
@@ -281,47 +282,48 @@ namespace OpenRA.Mods.Common.Lint
if (!field.IsLiteral)
continue;
var translationReference = Utility.GetCustomAttributes<TranslationReferenceAttribute>(field, true).SingleOrDefault();
if (translationReference == null)
var fluentReference = Utility.GetCustomAttributes<FluentReferenceAttribute>(field, true).SingleOrDefault();
if (fluentReference == null)
continue;
testedFields.Add(field);
var keys = LintExts.GetFieldValues(null, field, translationReference.DictionaryReference);
var keys = LintExts.GetFieldValues(null, field, fluentReference.DictionaryReference);
foreach (var key in keys)
usedKeys.Add(key, translationReference, $"`{field.ReflectedType.Name}.{field.Name}`");
usedKeys.Add(key, fluentReference, $"`{field.ReflectedType.Name}.{field.Name}`");
}
}
return (usedKeys, testedFields);
}
static void CheckModWidgets(ModData modData, TranslationKeys usedKeys, List<FieldInfo> testedFields)
static void CheckModWidgets(ModData modData, Keys usedKeys, List<FieldInfo> testedFields)
{
var chromeLayoutNodes = BuildChromeTree(modData);
var widgetTypes = modData.ObjectCreator.GetTypes()
.Where(t => t.Name.EndsWith("Widget", StringComparison.InvariantCulture) && t.IsSubclassOf(typeof(Widget)))
.ToList();
var translationReferencesByWidgetField = widgetTypes.SelectMany(t =>
var fluentReferencesByWidgetField = widgetTypes.SelectMany(t =>
{
var widgetName = t.Name[..^6];
return Utility.GetFields(t)
.Select(f =>
{
var attribute = Utility.GetCustomAttributes<TranslationReferenceAttribute>(f, true).SingleOrDefault();
return (WidgetName: widgetName, FieldName: f.Name, TranslationReference: attribute);
var attribute = Utility.GetCustomAttributes<FluentReferenceAttribute>(f, true).SingleOrDefault();
return (WidgetName: widgetName, FieldName: f.Name, FluentReference: attribute);
})
.Where(x => x.TranslationReference != null);
.Where(x => x.FluentReference != null);
})
.ToDictionary(
x => (x.WidgetName, x.FieldName),
x => x.TranslationReference);
x => x.FluentReference);
testedFields.AddRange(widgetTypes.SelectMany(
t => Utility.GetFields(t).Where(Utility.HasAttribute<TranslationReferenceAttribute>)));
t => Utility.GetFields(t).Where(Utility.HasAttribute<FluentReferenceAttribute>)));
foreach (var node in chromeLayoutNodes)
CheckChrome(node, translationReferencesByWidgetField, usedKeys);
CheckChrome(node, fluentReferencesByWidgetField, usedKeys);
}
static MiniYamlNode[] BuildChromeTree(ModData modData)
@@ -336,38 +338,38 @@ namespace OpenRA.Mods.Common.Lint
static void CheckChrome(
MiniYamlNode rootNode,
Dictionary<(string WidgetName, string FieldName), TranslationReferenceAttribute> translationReferencesByWidgetField,
TranslationKeys usedKeys)
Dictionary<(string WidgetName, string FieldName), FluentReferenceAttribute> fluentReferencesByWidgetField,
Keys usedKeys)
{
var nodeType = rootNode.Key.Split('@')[0];
foreach (var childNode in rootNode.Value.Nodes)
{
var childType = childNode.Key.Split('@')[0];
if (!translationReferencesByWidgetField.TryGetValue((nodeType, childType), out var translationReference))
if (!fluentReferencesByWidgetField.TryGetValue((nodeType, childType), out var reference))
continue;
var key = childNode.Value.Value;
usedKeys.Add(key, translationReference, $"Widget `{rootNode.Key}` field `{childType}` in {rootNode.Location}");
usedKeys.Add(key, reference, $"Widget `{rootNode.Key}` field `{childType}` in {rootNode.Location}");
}
foreach (var childNode in rootNode.Value.Nodes)
if (childNode.Key == "Children")
foreach (var n in childNode.Value.Nodes)
CheckChrome(n, translationReferencesByWidgetField, usedKeys);
CheckChrome(n, fluentReferencesByWidgetField, usedKeys);
}
static HashSet<string> CheckKeys(
IEnumerable<string> translationFiles, Func<string, Stream> openFile, TranslationKeys usedKeys,
IEnumerable<string> paths, Func<string, Stream> openFile, Keys usedKeys,
string language, Func<string, bool> checkUnusedKeysForFile,
Action<string> emitError, Action<string> emitWarning)
{
var keyWithAttrs = new HashSet<string>();
foreach (var file in translationFiles)
foreach (var path in paths)
{
if (!file.EndsWith($"{language}.ftl", StringComparison.Ordinal))
if (!path.EndsWith($"{language}.ftl", StringComparison.Ordinal))
continue;
var stream = openFile(file);
var stream = openFile(path);
using (var reader = new StreamReader(stream))
{
var parser = new LinguiniParser(reader);
@@ -388,9 +390,9 @@ namespace OpenRA.Mods.Common.Lint
foreach (var (node, attributeName) in nodeAndAttributeNames)
{
keyWithAttrs.Add(attributeName == null ? key : $"{key}.{attributeName}");
if (checkUnusedKeysForFile(file))
CheckUnusedKey(key, attributeName, file, usedKeys, emitWarning);
CheckVariables(node, key, attributeName, file, usedKeys, emitError, emitWarning);
if (checkUnusedKeysForFile(path))
CheckUnusedKey(key, attributeName, path, usedKeys, emitWarning);
CheckVariables(node, key, attributeName, path, usedKeys, emitError, emitWarning);
}
}
}
@@ -398,7 +400,7 @@ namespace OpenRA.Mods.Common.Lint
return keyWithAttrs;
static void CheckUnusedKey(string key, string attribute, string file, TranslationKeys usedKeys, Action<string> emitWarning)
static void CheckUnusedKey(string key, string attribute, string file, Keys usedKeys, Action<string> emitWarning)
{
var isAttribute = !string.IsNullOrEmpty(attribute);
var keyWithAtrr = isAttribute ? $"{key}.{attribute}" : key;
@@ -410,7 +412,7 @@ namespace OpenRA.Mods.Common.Lint
}
static void CheckVariables(
Pattern node, string key, string attribute, string file, TranslationKeys usedKeys,
Pattern node, string key, string attribute, string file, Keys usedKeys,
Action<string> emitError, Action<string> emitWarning)
{
var isAttribute = !string.IsNullOrEmpty(attribute);
@@ -456,26 +458,26 @@ namespace OpenRA.Mods.Common.Lint
}
}
class TranslationKeys
class Keys
{
readonly HashSet<string> keys = new();
readonly List<(string Key, string Context)> keysWithContext = new();
readonly Dictionary<string, HashSet<string>> requiredVariablesByKey = new();
readonly List<string> contextForEmptyKeys = new();
public void Add(string key, TranslationReferenceAttribute translationReference, string context)
public void Add(string key, FluentReferenceAttribute fluentReference, string context)
{
if (key == null)
{
if (!translationReference.Optional)
if (!fluentReference.Optional)
contextForEmptyKeys.Add(context);
return;
}
if (translationReference.RequiredVariableNames != null && translationReference.RequiredVariableNames.Length > 0)
if (fluentReference.RequiredVariableNames != null && fluentReference.RequiredVariableNames.Length > 0)
{
var rv = requiredVariablesByKey.GetOrAdd(key, _ => new HashSet<string>());
rv.UnionWith(translationReference.RequiredVariableNames);
rv.UnionWith(fluentReference.RequiredVariableNames);
}
keys.Add(key);

View File

@@ -18,7 +18,7 @@ using OpenRA.FileSystem;
namespace OpenRA.Mods.Common.Lint
{
sealed class CheckTranslationSyntax : ILintPass, ILintMapPass
sealed class CheckFluentSyntax : ILintPass, ILintMapPass
{
void ILintMapPass.Run(Action<string> emitError, Action<string> emitWarning, ModData modData, Map map)
{
@@ -33,11 +33,11 @@ namespace OpenRA.Mods.Common.Lint
Run(emitError, emitWarning, modData.DefaultFileSystem, modData.Manifest.Translations);
}
static void Run(Action<string> emitError, Action<string> emitWarning, IReadOnlyFileSystem fileSystem, string[] translations)
static void Run(Action<string> emitError, Action<string> emitWarning, IReadOnlyFileSystem fileSystem, string[] paths)
{
foreach (var file in translations)
foreach (var path in paths)
{
var stream = fileSystem.Open(file);
var stream = fileSystem.Open(path);
using (var reader = new StreamReader(stream))
{
var ids = new List<string>();
@@ -46,12 +46,12 @@ namespace OpenRA.Mods.Common.Lint
foreach (var entry in resource.Entries)
{
if (entry is Junk junk)
emitError($"{junk.GetId()}: {junk.AsStr()} in {file} {junk.Content}.");
emitError($"{junk.GetId()}: {junk.AsStr()} in {path} {junk.Content}.");
if (entry is AstMessage message)
{
if (ids.Contains(message.Id.Name.ToString()))
emitWarning($"Duplicate ID `{message.Id.Name}` in {file}.");
emitWarning($"Duplicate ID `{message.Id.Name}` in {path}.");
ids.Add(message.Id.Name.ToString());
}