refactor(claude-do): merge Material icons: delete dead Icon.* geometries + guard test

ClaudeDo-Task: 13b9cdfe-2b78-4764-9edb-8e944ec260ee
This commit is contained in:
mika kuns
2026-10-01 17:13:19 +02:00
4 changed files with 49 additions and 207 deletions
@@ -0,0 +1,43 @@
using System.Text.RegularExpressions;
using Material.Icons;
namespace ClaudeDo.Ui.Tests;
/// <summary>Guards every <c>mdi:Name</c> literal in the Ui sources: an unknown kind makes IconKeyConverter return null and the icon silently vanishes.</summary>
public class MdiIconNamesTests
{
/// <summary><c>mdi:Name</c> in XAML/C# plus <c>MdiGeometry("Name")</c> (MarkdownView prefixes the key itself).</summary>
private static readonly Regex NamePattern = new(@"mdi:(\w+)|MdiGeometry\(""(\w+)""\)", RegexOptions.Compiled);
[Fact]
public void EveryMdiNameInUiSources_IsAMaterialIconKind()
{
var uiDir = Path.Combine(FindRepoRoot(), "src", "ClaudeDo.Ui");
var files = Directory.EnumerateFiles(uiDir, "*.*", SearchOption.AllDirectories)
.Where(f => (f.EndsWith(".axaml") || f.EndsWith(".cs"))
&& !f.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}")
&& !f.Contains($"{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}"));
var unknown = new List<string>();
var seen = 0;
foreach (var file in files)
foreach (Match m in NamePattern.Matches(File.ReadAllText(file)))
{
seen++;
var name = m.Groups[1].Success ? m.Groups[1].Value : m.Groups[2].Value;
if (!Enum.TryParse<MaterialIconKind>(name, out _))
unknown.Add($"{Path.GetRelativePath(uiDir, file)}: {name}");
}
Assert.True(seen > 0, "scan found no mdi: names — the pattern or the repo-root lookup is broken");
Assert.True(unknown.Count == 0, "Unknown MaterialIconKind names:\n" + string.Join('\n', unknown));
}
private static string FindRepoRoot()
{
var dir = new DirectoryInfo(AppContext.BaseDirectory);
while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "ClaudeDo.slnx")))
dir = dir.Parent;
return dir?.FullName ?? throw new InvalidOperationException("ClaudeDo.slnx not found above " + AppContext.BaseDirectory);
}
}