Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for this one, @tkroes. A malformed A few points I would like to discuss with you before we merge. PlatformCop vs LinterCopI tend to place rules by what happens if they're ignored (see how the analyzers differ):
The rule doc justifies with "failed translation loading affects the whole extension". That is the PlatformCop consequence: the platform doesn't apply the translations and users see the base-language captions. It doesn't depend on any Base Application convention, so it isn't ApplicationCop either. It also isn't about procedure bodies, which is what LinterCop inspects. Could you move the rule to PlatformCop with the next free Severity: Warning rather than ErrorThe rule is on by default at Error, so anyone who upgrades ALCops with a malformed Code ReviewSome remarks on the implementaion of the code itself 1. Stream the file instead of building a DOM. private static readonly XmlReaderSettings WellFormedOnly = new()
{
DtdProcessing = DtdProcessing.Prohibit,
XmlResolver = null,
IgnoreComments = true,
IgnoreWhitespace = true,
};
using Stream stream = fileSystem.OpenRead(translationFile);
using var reader = XmlReader.Create(stream, WellFormedOnly);
while (reader.Read())
{
}
2. Discovery only catches catch (DirectoryNotFoundException)
{
return;
}
catch (Exception exception) when (exception is IOException or UnauthorizedAccessException)
{
ReportFileError(ctx, "Translations", $"Unable to enumerate translation files: {exception.Message}");
return;
}... or return silently if you'd rather not report this case. Either way it shouldn't crash. 3. Missing manifest: this rule and LC0091 behave differently. When the app's manifest ( NavAppManifest? manifest;
try
{
manifest = ManifestHelper.GetManifest(ctx.Compilation);
}
catch (FileNotFoundException)
{
manifest = null;
}
if (manifest is not null && !manifest.CompilerFeatures.ShouldGenerateTranslationFile())
return;
string appName = manifest?.AppName ?? string.Empty;TestsI see some errors in |
Summary
Adds LinterCop rule LC0100 TranslationFilesMustBeWellFormed to report malformed or unreadable translation files for the current app.
Location.None; XML parse errors include line and columnValidation
dotnet format ALCops.sln --verify-no-changes: clean.clauderule validation: passed/code-review: no significant issues foundDocs-site page in the sibling
alcops.devrepo remains to be written.