{"record":{"id":"85e56c43b63e5abe","repo":"dotnet/maui","slug":"unsupported-path-part-type-nextpart-gettype","errorCode":null,"errorMessage":"Unsupported path part type: {nextPart.GetType()}","messagePattern":"Unsupported path part type: (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/BindingSourceGen/AccessExpressionBuilder.cs","lineNumber":23,"sourceCode":"\npublic static class AccessExpressionBuilder\n{\n\t/// <summary>\n\t/// Extends an expression by accessing the next part of a binding path.\n\t/// This is used for getter paths (reading values), not for setter assignments.\n\t/// </summary>\n\tpublic static string ExtendExpression(string previousExpression, IPathPart nextPart)\n\t\t=> nextPart switch\n\t\t{\n\t\t\tCast { TargetType: var targetType } => $\"({previousExpression} as {CastTargetName(targetType)})\",\n\t\t\tConditionalAccess conditionalAccess => ExtendExpression(previousExpression: $\"{previousExpression}?\", conditionalAccess.Part),\n\t\t\tIndexAccess { Index: int numericIndex } => $\"{previousExpression}[{numericIndex}]\",\n\t\t\tIndexAccess { Index: EnumIndex enumIndex } => $\"{previousExpression}[{enumIndex.FullyQualifiedEnumValue}]\",\n\t\t\tIndexAccess { Index: string stringIndex } => $\"{previousExpression}[\\\"{stringIndex}\\\"]\",\n\t\t\tMemberAccess { Kind: AccessorKind.Field, IsGetterInaccessible: true } memberAccess => $\"{CreateUnsafeFieldAccessorMethodName(memberAccess.MemberName)}({previousExpression})\",\n\t\t\tMemberAccess { Kind: AccessorKind.Property, IsGetterInaccessible: true } memberAccess => $\"{CreateUnsafePropertyAccessorGetMethodName(memberAccess.MemberName)}({previousExpression})\",\n\t\t\tMemberAccess memberAccess => $\"{previousExpression}.{memberAccess.MemberName}\",\n\t\t\t_ => throw new NotSupportedException($\"Unsupported path part type: {nextPart.GetType()}\"),\n\t\t};\n\n\tprivate static string CastTargetName(TypeDescription targetType)\n\t\t=> targetType.IsValueType ? $\"{targetType.GlobalName}?\" : targetType.GlobalName;\n}\n","sourceCodeStart":5,"sourceCodeEnd":29,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/BindingSourceGen/AccessExpressionBuilder.cs#L5-L29","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["source-generator","bindings","compilation","internal","csharp"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}