fix(app): settings list column width is a GridLength; lint resource value types

The Settings screen sized its section column from a Double resource;
ColumnDefinition.Width needs a GridLength, so the template failed to
load on Windows. xaml-lint now compares keyed Double, GridLength,
Thickness and CornerRadius resources with the property they are used
for, so this fails on Linux too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 13:05:24 +00:00
1 parent b6c6aa67ee
commit 34505dfe79
4 files changed
+42 -4

No files matched your search

+1
View File
@@ -122,3 +122,4 @@ One line per decision: date · decision · alternative · reason.
| 2026-10-02 | Render jobs never run on the server engine: render nodes claim them by codec and resolution, report failures, and a job fails after losing its node 5 times. | Managed rendering on the server | No server render handler yet. |
| 2026-10-02 | Server settings page writes only edited keys to `server.json`; environment-fixed settings are locked; restart-only keys are flagged. Windows service: LocalSystem, automatic start, name `TitanoServer`. Admin panel: strict CSP (SVG charts, no inline styles), light theme only. | Rewrite the whole file / theme toggle | Secrets never written; DESIGN.md wins over the mockup toggle. |
| 2026-10-02 | Migrations are numbered without gaps (0001 initial, 0002 archive index, 0003 server uploads). | Keep 0005 | Parallel workstreams picked numbers to avoid collisions; renumbered at merge. |
| 2026-10-02 | `xaml-lint` checks keyed value resources against the property type (GridLength for column/row sizes, Thickness, CornerRadius, Double). | Rely on Windows smoke tests | A Double used as a column width compiles and only fails when the template loads on Windows; the lint now fails on Linux too. |
+1 -1
View File
@@ -28,7 +28,7 @@
<Grid Margin="20,16,20,16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Width.SettingsList}" />
<ColumnDefinition Width="{StaticResource Grid.SettingsList}" />
<ColumnDefinition Width="16" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
+39 -2
View File
@@ -28,9 +28,11 @@ internal sealed class XamlLintCommand : ICommand
&& !f.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}", StringComparison.Ordinal))
.ToList();
foreach (var file in files)
var documents = files.Select(f => (File: f, Doc: XDocument.Load(f, LoadOptions.SetLineInfo))).ToList();
var valueTypes = ValueResourceTypes(documents.Select(d => d.Doc));
foreach (var (file, doc) in documents)
{
var doc = XDocument.Load(file, LoadOptions.SetLineInfo);
foreach (var el in doc.Descendants())
{
var line = ((System.Xml.IXmlLineInfo)el).LineNumber;
@@ -52,6 +54,13 @@ internal sealed class XamlLintCommand : ICommand
problems.Add($"{where}: literal {attrName}=\"{v}\" on <{name}> (use {{l:Loc …}})");
}
foreach (var attr in el.Attributes())
{
if (ExpectedValueType(name, attr.Name.LocalName) is not { } expected || ResourceKey(attr.Value) is not { } key) continue;
if (valueTypes.TryGetValue(key, out var actual) && actual != expected)
problems.Add($"{where}: {name}.{attr.Name.LocalName} needs a {expected} but resource {key} is a {actual}");
}
// Literal element content such as <TextBlock>Hello</TextBlock> or <Run>Hi</Run>.
if (name is "TextBlock" or "Run" or "Label" or "Button" && !el.HasElements && el.Value.Any(char.IsLetter))
problems.Add($"{where}: literal text in <{name}>");
@@ -63,6 +72,34 @@ internal sealed class XamlLintCommand : ICommand
return Task.FromResult(problems.Count == 0 ? 0 : 1);
}
/// <summary>Keyed resources of the value types WPF cannot convert into each other at run time (parsing succeeds, loading fails).</summary>
private static Dictionary<string, string> ValueResourceTypes(IEnumerable<XDocument> documents)
{
var types = new Dictionary<string, string>(StringComparer.Ordinal);
foreach (var el in documents.SelectMany(d => d.Descendants()))
{
if (el.Name.LocalName is not ("Double" or "GridLength" or "Thickness" or "CornerRadius")) continue;
if (el.Attributes().FirstOrDefault(a => a.Name.LocalName == "Key") is { } key) types[key.Value] = el.Name.LocalName;
}
return types;
}
private static string? ExpectedValueType(string element, string attribute) => attribute switch
{
"Width" when element == "ColumnDefinition" => "GridLength",
"Height" when element == "RowDefinition" => "GridLength",
"Margin" or "Padding" or "BorderThickness" => "Thickness",
"CornerRadius" => "CornerRadius",
"Width" or "Height" or "MinWidth" or "MaxWidth" or "MinHeight" or "MaxHeight" or "FontSize" => "Double",
_ => null,
};
private static string? ResourceKey(string value)
{
var match = System.Text.RegularExpressions.Regex.Match(value, @"^\{(?:Static|Dynamic)Resource\s+(?:ResourceKey=)?([^\s}]+)\s*\}$");
return match.Success ? match.Groups[1].Value : null;
}
private static bool HasToolTip(XElement el) =>
el.Attribute("ToolTip") is not null
|| el.Elements().Any(c => c.Name.LocalName.EndsWith(".ToolTip", StringComparison.Ordinal))
+1 -1
View File
@@ -34,7 +34,7 @@
<sys:Double x:Key="Width.Rail">128</sys:Double>
<sys:Double x:Key="Width.RailCollapsed">48</sys:Double>
<sys:Double x:Key="Width.SidePanel">320</sys:Double>
<sys:Double x:Key="Width.SettingsList">200</sys:Double>
<GridLength x:Key="Grid.SettingsList">200</GridLength>
<GridLength x:Key="Grid.LabelColumn">116</GridLength>
<GridLength x:Key="Grid.SettingsLabelColumn">180</GridLength>