File-New-Project/EarTrumpet · error · NotImplementedException
bad number of /
Error message
bad number of /
What it means
ParseOpacityFromColor encodes optional alpha in the color name itself using slashes: "Color", "Color/opacity", or "Color/opacity/opacityNoTransparency". It splits on '/' and only accepts 1, 2, or 3 segments. Anything else (4+ segments) is a malformed value and throws NotImplementedException("bad number of /").
Source
Thrown at EarTrumpet/UI/Themes/BrushValueParser.cs:255
var parts = colorName.Split('/');
if (parts.Length == 1)
{
// Nothing to do.
}
else if (parts.Length == 2)
{
opacity = double.Parse(parts[1], CultureInfo.InvariantCulture);
colorName = parts[0];
}
else if (parts.Length == 3)
{
opacity = double.Parse(parts[1], CultureInfo.InvariantCulture);
opacityNoTransparency = double.Parse(parts[2], CultureInfo.InvariantCulture);
colorName = parts[0];
}
else
{
throw new NotImplementedException("bad number of /");
}
desiredOpacity = SystemSettings.IsTransparencyEnabled && !SystemParameters.HighContrast ? opacity : (opacityNoTransparency > 0 ? opacityNoTransparency : opacity);
return colorName;
}
}
}View on GitHub (pinned to aa894e51c2)
Solutions
- Correct the color string to at most two slashes: "Color", "Color/0.5", or "Color/0.5/0.3".
- Strip trailing/empty segments before splitting if user-supplied markup is the source.
- Validate the segment count before calling Parse and reject malformed values early.
- Check reference concatenation sites (FindReference builds "+ opacities") for double slashes.
Example fix
// before: value = "Accent/0.5/0.3/0.1"
// after: value = "Accent/0.5/0.3"
// guard:
var parts = colorName.Split('/');
if (parts.Length > 3) throw new FormatException($"Too many '/' segments: {colorName}"); Defensive patterns
Strategy: validation
Validate before calling
// validate slash count before ParseOpacityFromColor
var parts = colorName.Split('/');
if (parts.Length < 1 || parts.Length > 3)
throw new FormatException($"Invalid color/opacity format: '{colorName}'"); Try / catch
try { colorName = ParseOpacityFromColor(colorName, out var opacity); }
catch (NotImplementedException ex) { throw new FormatException($"Bad opacity format: {colorName}", ex); } Prevention
- Limit opacity markup to at most two slashes (Color/opacity/opacityNoTransparency).
- Trim trailing slashes and empty segments from user/template markup before parsing.
- Check reference concatenation sites (FindReference appends opacities) to avoid doubling slashes.
When it happens
Trigger: A theme color value is passed with more than two slashes, e.g. "Accent/0.5/0.3/extra" or "Red/1/2/3", so parts.Length >= 4 and the final else throws.
Common situations: Typo adding an extra slash; a reference value concatenation that accidentally appends another "/opacity"; copy-paste of an opacity expression with a trailing slash.
Related errors
AI-assisted analysis of File-New-Project/EarTrumpet@aa894e51c2 (2026-08-13).
Data as JSON: /api/errors/e2089161e6fadff2.
Report an issue: GitHub.