File-New-Project/EarTrumpet · error · NotImplementedException
BrushValueParser: '{value}'
Error message
BrushValueParser: '{value}' What it means
BrushValueParser.Parse resolves a WPF theme brush from a compact markup string (e.g. "Theme=Transparent", "Flyout:Theme=Transparent, HighContrast=Window"). In HighContrast mode it tries, in order, the keys "" (default), "HighContrast", "Theme", "Light"; if none of those keys is present in the chosen scope map it throws NotImplementedException. The throw means the theme value provides no usable color for the active HighContrast state.
Source
Thrown at EarTrumpet/UI/Themes/BrushValueParser.cs:100
if (map.ContainsKey(""))
{
colorName = map[""];
}
else if (map.ContainsKey("HighContrast"))
{
colorName = map["HighContrast"];
}
else if (map.ContainsKey("Theme"))
{
colorName = map["Theme"].Replace("{Theme}", "Light");
}
else if (map.ContainsKey("Light"))
{
colorName = map["Light"];
}
else
{
throw new NotImplementedException($"BrushValueParser: '{value}'");
}
}
else
{
if (map.ContainsKey(""))
{
colorName = map[""];
}
else if (map.ContainsKey("Theme"))
{
colorName = map["Theme"].Replace("{Theme}", isLight ? "Light" : "Dark");
}
else if (map.ContainsKey("Light") && isLight)
{
colorName = map["Light"];
}
else if (map.ContainsKey("Dark") && !isLight)
{
View on GitHub (pinned to aa894e51c2)
Solutions
- Add a default "" entry or a "HighContrast=" entry to the offending brush value so the high-contrast branch resolves.
- Provide a "Theme=" entry (it is substituted as Light in HC) if you want one value to cover HC.
- Audit all BrushValueParser markup strings for coverage across "", HighContrast, Theme, Light, Dark.
- Test theme loading with High Contrast enabled.
Example fix
// before (XAML/theme markup): "Header:Dark=AccentColor" // after: "Header:Dark=AccentColor, HighContrast=WindowColor" // or simply: "AccentColor" (default key covers all modes)
Defensive patterns
Strategy: validation
Validate before calling
// validate a brush value covers high contrast before parsing
bool CoversHighContrast(Dictionary<string,string> map)
=> map.ContainsKey("") || map.ContainsKey("HighContrast") || map.ContainsKey("Theme") || map.ContainsKey("Light"); Try / catch
try { return BrushValueParser.Parse(element, value); } catch (Exception ex) { Trace.WriteLine($"{ex.Message} inner={ex.InnerException?.Message}"); return FallbackBrush; } Prevention
- Always provide a default "" or Theme key for each brush so all modes resolve.
- Test theme loading with High Contrast on.
- CI: lint theme markup to require a high-contrast-covering key per scope.
When it happens
Trigger: SystemParameters.HighContrast is true and a theme brush value contains only a "Dark=..." entry (or a scope that lacks ""/"HighContrast"/"Theme"/"Light"), so the high-contrast branch falls through to the throw.
Common situations: A theme author added a new brush with only a Dark variant; a scoped value ("Header:Dark=...") was added without a high-contrast fallback; high-contrast testing was skipped.
Related errors
AI-assisted analysis of File-New-Project/EarTrumpet@aa894e51c2 (2026-08-13).
Data as JSON: /api/errors/c510eca810989562.
Report an issue: GitHub.