{"record":{"id":"3b86197047e78a80","repo":"unoplatform/uno","slug":"local-values-are-not-allowed-in-resource-dictionar","errorCode":null,"errorMessage":"Local values are not allowed in resource dictionary with Source set","messagePattern":"Local values are not allowed in resource dictionary with Source set","errorType":"exception","errorClass":"XamlGenerationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs","lineNumber":3046,"sourceCode":"\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isInInitializer)\n\t\t\t{\n\t\t\t\twriter.AppendLineInvariantIndented(\"{0} = {{\", propertyName);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\twriter.AppendLineInvariantIndented(\"// {0}\", propertyName);\n\t\t\t}\n\n\t\t\tfor (int i = 0; i < dictionaries.Objects.Count; i++)\n\t\t\t{\n\t\t\t\tvar dictObject = dictionaries.Objects[i];\n\t\t\t\tvar source = dictObject.Members.FirstOrDefault(m => m.Member.Name == \"Source\");\n\t\t\t\tif (source != null && dictObject.Members.Any(m => m.Member.Name == \"_UnknownContent\"))\n\t\t\t\t{\n\t\t\t\t\tthrow new XamlGenerationException(\"Local values are not allowed in resource dictionary with Source set\", dictObject);\n\t\t\t\t}\n\n\t\t\t\tvar key = GetDictionaryResourceKey(dictObject);\n\t\t\t\tif (isDict && key == null)\n\t\t\t\t{\n\t\t\t\t\tthrow new XamlGenerationException(\"Each dictionary entry must have a 'Key'\", dictObject);\n\t\t\t\t}\n\n\t\t\t\tvar former = _themeDictionaryCurrentlyBuilding; //Will 99% of the time be null.\n\t\t\t\tif (isDict)\n\t\t\t\t{\n\t\t\t\t\t_themeDictionaryCurrentlyBuilding = key;\n\t\t\t\t}\n\n\t\t\t\tif (!isSetExtensionMethod)\n\t\t\t\t{\n\t\t\t\t\tif (!isInInitializer && !isDict)\n\t\t\t\t\t{","sourceCodeStart":3028,"sourceCodeEnd":3064,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs#L3028-L3064","documentation":"Thrown in the dictionary-building loop when a ResourceDictionary entry has both a Source member and _UnknownContent (i.e. local inline entries) set. WinUI/Uno semantics: a ResourceDictionary that references an external Source file cannot also contain locally-defined entries in the same element. The two are mutually exclusive because the Source fully defines the dictionary contents.","triggerScenarios":"Writing <ResourceDictionary Source=\"...\"> with child <Style>/<Brush> entries directly inside the same element; combining MergedDictionaries Source references with inline resources at the wrong nesting level.","commonSituations":"Attempting to add a local override alongside a merged dictionary in the same tag; misunderstanding that Source and local content must be in separate ResourceDictionary elements.","solutions":["Split into two elements: one <ResourceDictionary Source=\"...\"/> inside <MergedDictionaries>, and a sibling for local entries at the parent level.","Move local resources into the parent ResourceDictionary (not inside the Source-referenced one).","If you only need the external dictionary, remove the inline entries."],"exampleFix":"<!-- before -->\n<ResourceDictionary Source=\"ms-appx:///Shared.xaml\">\n  <SolidColorBrush x:Key=\"Local\" Color=\"Red\"/>\n</ResourceDictionary>\n\n<!-- after -->\n<ResourceDictionary>\n  <ResourceDictionary.MergedDictionaries>\n    <ResourceDictionary Source=\"ms-appx:///Shared.xaml\"/>\n  </ResourceDictionary.MergedDictionaries>\n  <SolidColorBrush x:Key=\"Local\" Color=\"Red\"/>\n</ResourceDictionary>","handlingStrategy":"validation","validationCode":"# Flag <ResourceDictionary Source=\"...\"> that also contains child elements\nGet-ChildItem -Recurse -Filter *.xaml | ForEach-Object {\n  $text = Get-Content $_.FullName -Raw\n  [regex]::Matches($text, '<ResourceDictionary\\s+[^>]*Source=\"[^\"]+\"[^>]*>(.*?)</ResourceDirectory>', 'Singleline') |\n    ForEach-Object { if ($_.Groups[1].Value -match '<') { Write-Warning \"ResourceDictionary with Source has local content\" } }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember: a Source-referenced ResourceDictionary is a leaf — put local resources in the parent dictionary.","Use the MergedDictionaries pattern: parent ResourceDictionary > .MergedDictionaries > child Source dictionaries."],"tags":["xaml","resource-dictionary","merged-dictionaries","build"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}