{"record":{"id":"0df7b6e3ef7ba744","repo":"dotnet/maui","slug":"member-member-membername-with-inaccessible-acc","errorCode":null,"errorMessage":"Member '{member.MemberName}' with inaccessible accessor must have MemberType and ContainingType populated.","messagePattern":"Member '(.+?)' with inaccessible accessor must have MemberType and ContainingType populated\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/BindingSourceGen/BindingCodeWriter.cs","lineNumber":428,"sourceCode":"\t\t\t\n\t\t\tUnindent();\n\t\t\tAppend('}');\n\t\t}\n\n\t\tprivate void AppendUnsafeAccessors(BindingInvocationDescription binding)\n\t\t{\n\t\t\t// Append unsafe accessors as local methods for members with inaccessible accessors\n\t\t\tvar membersWithInaccessibleAccessors = binding.Path.OfType<MemberAccess>().Where(m => m.HasInaccessibleAccessor);\n\n\t\t\tforeach (var member in membersWithInaccessibleAccessors)\n\t\t\t{\n\t\t\t\tAppendBlankLine();\n\n\t\t\t\t// Members with inaccessible accessors must have MemberType and ContainingType populated\n\t\t\t\t// by PathParser during source analysis\n\t\t\t\tif (member.MemberType == null || member.ContainingType == null)\n\t\t\t\t{\n\t\t\t\t\tthrow new InvalidOperationException($\"Member '{member.MemberName}' with inaccessible accessor must have MemberType and ContainingType populated.\");\n\t\t\t\t}\n\n\t\t\t\tif (member.Kind == AccessorKind.Field)\n\t\t\t\t{\n\t\t\t\t\tAppendUnsafeFieldAccessor(member.MemberName, member.MemberType.GlobalName, member.ContainingType.GlobalName);\n\t\t\t\t}\n\t\t\t\telse if (member.Kind == AccessorKind.Property)\n\t\t\t\t{\n\t\t\t\t\tbool isLastPart = member.Equals(binding.Path.Last());\n\t\t\t\t\tbool needsGetterForLastPart = binding.RequiresAllUnsafeGetters;\n\n\t\t\t\t\tif (member.IsGetterInaccessible && (!isLastPart || needsGetterForLastPart))\n\t\t\t\t\t{\n\t\t\t\t\t\t// we don't need the unsafe getter if the item is the very last part of the path\n\t\t\t\t\t\t// because we don't need to access its value while constructing the handlers array\n\t\t\t\t\t\tAppendUnsafePropertyGetAccessors(member.MemberName, member.MemberType.GlobalName, member.ContainingType.GlobalName);\n\t\t\t\t\t}\n","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/BindingSourceGen/BindingCodeWriter.cs#L410-L446","documentation":"An internal source-generator invariant in BindingSourceGen. When a compiled binding path contains a member whose getter or setter is inaccessible (non-public), the generator emits an unsafe accessor and requires PathParser to have populated MemberType and ContainingType metadata for that member. This InvalidOperationException fires only if that metadata is missing, signalling a coordination gap between PathParser and BindingCodeWriter rather than a user mistake.","triggerScenarios":"Binding to a property or field whose accessor is private/internal/protected, in a case where PathParser could not capture the member's type and declaring type (e.g. symbol info unavailable across assembly boundaries, partial generics, or a newer Maui version).","commonSituations":"Binding to a member with non-public accessors located in another assembly; source-generator/analysis version skew; binding to a type whose symbol metadata is incomplete during generation.","solutions":["Make the bound member's accessor public if the type is yours, which bypasses the unsafe-accessor code path entirely.","Reproduce with the minimal binding and file a Maui issue, since this is a generator invariant violation.","Ensure Maui SDK/package versions are consistent across projects to avoid generator/analysis mismatches."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer binding to public members so the unsafe-accessor code path is not triggered.","Keep BindingSourceGen analysis and code-writer packages version-aligned.","Reproduce with a minimal binding and file an upstream issue if the invariant fires."],"tags":["source-generator","bindings","unsafe-accessors","internal","csharp"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}