AvaloniaUI/Avalonia · error · NotSupportedException

Unsupported command

Error message

Unsupported command

What it means

A defensive throw in the default branch of the command-dispatch switch inside Parse(). ReadCommand only ever returns Command values that exist in the s_commands lookup table (F,M,L,H,V,Q,T,C,S,A,Z), so every enum value the switch sees is already covered by an explicit case. This default is effectively unreachable for real input; it exists to keep the switch exhaustive and to fail loudly if the Command enum gains a member that is never wired into the switch.

Source

Thrown at src/Avalonia.Base/Media/PathMarkupParser.cs:161

                            AddCubicBezierCurve(ref span, relative);
                            break;
                        case Command.QuadraticBezierCurve:
                            AddQuadraticBezierCurve(ref span, relative);
                            break;
                        case Command.SmoothCubicBezierCurve:
                            AddSmoothCubicBezierCurve(ref span, relative);
                            break;
                        case Command.SmoothQuadraticBezierCurve:
                            AddSmoothQuadraticBezierCurve(ref span, relative);
                            break;
                        case Command.Arc:
                            AddArc(ref span, relative);
                            break;
                        case Command.Close:
                            CloseFigure();
                            break;
                        default:
                            throw new NotSupportedException("Unsupported command");
                    }

                    initialCommand = false;
                } while (PeekArgument(span));
                
            }

            if (_isOpen)
            {
                _geometryContext.EndFigure(false);
            }
        }

        private void CreateFigure()
        {
            ThrowIfDisposed();

            if (_isOpen)

View on GitHub (pinned to 11c5427268)

Solutions

  1. If you extended the Command enum, add the matching case in the Parse() switch (line ~123).
  2. Do not chase this as a data error — your path string is not the cause.
  3. Add a unit test covering any new command so the switch stays exhaustive.
Defensive patterns

Strategy: try-catch

Try / catch

try { parser.Parse(data); }
catch (NotSupportedException) { /* internal/defensive: report a library bug, not bad input */ }

Prevention

When it happens

Trigger: Not triggerable through any path markup string. Would only fire if a developer added a new Command enum value and a corresponding s_commands entry but forgot to add a case in Parse().

Common situations: Internal contributors extending the path command set. End users hitting this should suspect a corrupted/custom build rather than bad data.

Related errors


AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13). Data as JSON: /api/errors/fdd6ee7d7ef0a042. Report an issue: GitHub.