dotnet/maui · error · NotSupportedException
Unsupported path part type: {nextPart.GetType()}
Error message
Unsupported path part type: {nextPart.GetType()} What it means
An internal source-generator invariant in Maui's BindingSourceGen. AccessExpressionBuilder.ExtendExpression emits a C# access expression for each part of a compiled binding path and exhaustively pattern-matches the known IPathPart records (Cast, ConditionalAccess, IndexAccess with int/Enum/string index, MemberAccess). The default arm throws NotSupportedException only if a path part of an unrecognized type reaches it, which indicates a generator gap or version skew rather than user error.
Source
Thrown at src/Controls/src/BindingSourceGen/AccessExpressionBuilder.cs:23
public static class AccessExpressionBuilder
{
/// <summary>
/// Extends an expression by accessing the next part of a binding path.
/// This is used for getter paths (reading values), not for setter assignments.
/// </summary>
public static string ExtendExpression(string previousExpression, IPathPart nextPart)
=> nextPart switch
{
Cast { TargetType: var targetType } => $"({previousExpression} as {CastTargetName(targetType)})",
ConditionalAccess conditionalAccess => ExtendExpression(previousExpression: $"{previousExpression}?", conditionalAccess.Part),
IndexAccess { Index: int numericIndex } => $"{previousExpression}[{numericIndex}]",
IndexAccess { Index: EnumIndex enumIndex } => $"{previousExpression}[{enumIndex.FullyQualifiedEnumValue}]",
IndexAccess { Index: string stringIndex } => $"{previousExpression}[\"{stringIndex}\"]",
MemberAccess { Kind: AccessorKind.Field, IsGetterInaccessible: true } memberAccess => $"{CreateUnsafeFieldAccessorMethodName(memberAccess.MemberName)}({previousExpression})",
MemberAccess { Kind: AccessorKind.Property, IsGetterInaccessible: true } memberAccess => $"{CreateUnsafePropertyAccessorGetMethodName(memberAccess.MemberName)}({previousExpression})",
MemberAccess memberAccess => $"{previousExpression}.{memberAccess.MemberName}",
_ => throw new NotSupportedException($"Unsupported path part type: {nextPart.GetType()}"),
};
private static string CastTargetName(TypeDescription targetType)
=> targetType.IsValueType ? $"{targetType.GlobalName}?" : targetType.GlobalName;
}
View on GitHub (pinned to f377ff1c5e)
Solutions
- Simplify the binding path (remove casts/indices/method-like constructs) to isolate which part triggers it.
- Align all Maui workload/package versions across the solution so source-generator and analysis assemblies match.
- File a Maui issue with the exact Binding expression and types so the generator's switch can be extended.
Defensive patterns
Strategy: validation
Prevention
- Keep Maui SDK and source-generator package versions identical across all projects in the solution.
- Avoid exotic binding path constructs (casts, unusual indexers) when simpler paths work.
- When upgrading Maui, rebuild clean and report any unsupported-path-part errors upstream with a minimal repro.
When it happens
Trigger: A compiled binding path resolves to an IPathPart subtype not handled by the switch (e.g. a new index kind, a method-call node, or a path construct introduced by a newer Maui version before the generator was updated).
Common situations: Mixing Maui package versions across projects so the path-analysis and expression-building generators disagree; binding to an exotic expression after a Maui upgrade; a genuine generator bug for an unusual path.
Related errors
- Member '{member.MemberName}' with inaccessible accessor must
- IItemsViewSource is empty
- mainRenderer
- Unhandled expression type: '{0}'
- Unhandled binding type '{0}'
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/85e56c43b63e5abe.
Report an issue: GitHub.