{"record":{"id":"b749a59b8ac7e3e9","repo":"unoplatform/uno","slug":"field-modifier-accessibility-is-not-supported","errorCode":null,"errorMessage":"Field modifier {accessibility} is not supported","messagePattern":"Field modifier (.+?) is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.Reflection.cs","lineNumber":253,"sourceCode":"\n\t\t\treturn Accessibility.Private;\n\t\t}\n\n\t\tprivate string FormatAccessibility(Accessibility accessibility)\n\t\t{\n\t\t\tswitch (accessibility)\n\t\t\t{\n\t\t\t\tcase Accessibility.Private:\n\t\t\t\t\treturn \"private\";\n\n\t\t\t\tcase Accessibility.Internal:\n\t\t\t\t\treturn \"internal\";\n\n\t\t\t\tcase Accessibility.Public:\n\t\t\t\t\treturn \"public\";\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new NotSupportedException($\"Field modifier {accessibility} is not supported\");\n\t\t\t}\n\t\t}\n\n\t\tprivate INamedTypeSymbol GetPropertyTypeByOwnerSymbol(INamedTypeSymbol ownerType, string propertyName, int lineNumber, int linePosition, [CallerMemberName] string caller = \"\")\n\t\t{\n\t\t\tvar definition = _metadataHelper.FindPropertyTypeByOwnerSymbol(ownerType, propertyName);\n\n\t\t\tif (definition == null)\n\t\t\t{\n\t\t\t\tthrow new Exception($\"The property {ownerType}.{propertyName} is unknown. Line number: {lineNumber}, Line position: {linePosition}, Caller: {caller}, File: {_fileDefinition.FilePath}\");\n\t\t\t}\n\n\t\t\treturn definition;\n\t\t}\n\n\t\tprivate ISymbol? FindProperty(XamlMember xamlMember)\n\t\t{\n\t\t\tvar type = FindType(xamlMember.DeclaringType);","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.Reflection.cs#L235-L271","documentation":"Thrown by the accessibility-to-string conversion method when a field's Accessibility value does not match Private, Internal, or Public. The switch has a default case that throws NotSupportedException for any other accessibility level (Protected, ProtectedOrInternal, ProtectedAndInternal, etc.).","triggerScenarios":"A field used in XAML code generation (e.g. an x:Bind source field or a named element backing field) has a protected or protected-internal accessibility modifier.","commonSituations":"A field declared as 'protected' in a base class or partial class is picked up by the XAML generator; code that was refactored from public to protected without updating XAML bindings; an inherited protected field is bound via x:Bind.","solutions":["Change the field's accessibility to public, internal, or private.","If the field is inherited and cannot be changed, create a public/internal wrapper property and bind to that instead.","Move the field declaration to a context where it can be public/internal."],"exampleFix":"// before\nprotected string _myValue;\n<!-- XAML binds to _myValue -->\n// after\npublic string MyValue { get => _myValue; set => _myValue = value; }","handlingStrategy":"validation","validationCode":"// Check field accessibility before binding in XAML:\n// var fields = typeof(MyPage).GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);\n// foreach (var f in fields.Where(f => f.IsFamily || f.IsFamilyOrAssembly))\n//     Console.WriteLine($\"Field {f.Name} is {f.Attributes} — change to public/internal/private for XAML\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use public or internal accessibility for fields bound in XAML.","Prefer properties over fields for XAML data binding.","Avoid protected fields in types involved in XAML code generation."],"tags":["reflection","xaml","source-generator","accessibility"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}