{"record":{"id":"2b6fe96ab07e2883","repo":"unoplatform/uno","slug":"unable-to-resolve-symbol-reason-errortypesymb","errorCode":null,"errorMessage":"Unable to resolve {symbol} (Reason: {errorTypeSymbol.CandidateReason}, Location:{location}, Candidates: {candidates})","messagePattern":"Unable to resolve (.+?) \\(Reason: (.+?), Location:(.+?), Candidates: (.+?)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/Uno.UI.SourceGenerators/RoslynMetadataHelper.cs","lineNumber":47,"sourceCode":"\n\t\t\t_findTypeByFullName = Funcs.Create<string, ITypeSymbol?>(SourceFindTypeByFullName).AsLockedMemoized();\n\t\t\t_findContentProperty = Funcs.Create<INamedTypeSymbol, IPropertySymbol?>(SourceFindContentProperty).AsLockedMemoized();\n\t\t\t_isAttachedProperty = Funcs.Create<INamedTypeSymbol?, string, bool>(SourceIsAttachedProperty).AsLockedMemoized();\n\t\t\t_getAttachedPropertyType = Funcs.Create<INamedTypeSymbol, string, INamedTypeSymbol>(SourceGetAttachedPropertyType).AsLockedMemoized();\n\t\t\t_isTypeImplemented = Funcs.Create<INamedTypeSymbol, bool>(SourceIsTypeImplemented).AsLockedMemoized();\n\t\t\t_findPropertyByOwnerSymbol = Funcs.Create<INamedTypeSymbol?, string, ISymbol?>(SourceFindPropertyByOwnerSymbol).AsLockedMemoized();\n\t\t\t_findLocalizableDeclaredProperties = Funcs.Create<INamedTypeSymbol, string[]>(SourceFindLocalizableDeclaredProperties).AsLockedMemoized();\n\t\t\t_findEventType = Funcs.Create<INamedTypeSymbol?, string, IEventSymbol?>(SourceFindEventType).AsLockedMemoized();\n\t\t}\n\n\t\tprivate static void ThrowOnErrorSymbol(ISymbol symbol)\n\t\t{\n\t\t\tif (symbol is IErrorTypeSymbol errorTypeSymbol)\n\t\t\t{\n\t\t\t\tvar candidates = string.Join(\";\", errorTypeSymbol.CandidateSymbols);\n\t\t\t\tvar location = symbol.Locations.FirstOrDefault()?.ToString() ?? \"Unknown\";\n\n\t\t\t\tthrow new InvalidOperationException(\n\t\t\t\t\t$\"Unable to resolve {symbol} (Reason: {errorTypeSymbol.CandidateReason}, Location:{location}, Candidates: {candidates})\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tpublic ITypeSymbol? FindTypeByFullName(string fullName)\n\t\t{\n\t\t\treturn _findTypeByFullName(fullName);\n\t\t}\n\n\t\tprivate ITypeSymbol? SourceFindTypeByFullName(string fullName)\n\t\t{\n\t\t\tvar symbol = Compilation.GetTypeByMetadataName(fullName);\n\n\t\t\tif (symbol?.Kind == SymbolKind.ErrorType)\n\t\t\t{\n\t\t\t\tsymbol = null;\n\t\t\t}","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/Uno.UI.SourceGenerators/RoslynMetadataHelper.cs#L29-L65","documentation":"ThrowOnErrorSymbol inspects a resolved symbol and, if it is an IErrorTypeSymbol, throws InvalidOperationException with the CandidateReason, source location, and candidate symbols. Roslyn produces an IErrorTypeSymbol when a name resolves ambiguously to multiple candidates or cannot be bound, so this surfaces ambiguous/unresolvable XAML type references.","triggerScenarios":"A XAML type reference resolves to multiple candidate symbols (ambiguous) or none, e.g. two referenced assemblies each define a type with the same name and both namespaces are in scope.","commonSituations":"Adding a PackageReference that introduces a duplicate type name; an xmlns pulling in multiple namespaces with a clashing type; a rename that leaves the old type shadowed.","solutions":["Read the reported candidates and qualify the XAML type with the fully-qualified xmlns of the intended one.","Remove or alias the conflicting PackageReference/ProjectReference.","Use an explicit xmlns prefix mapped to the correct namespace/assembly."],"exampleFix":"<!-- before: 'Button' ambiguous across two namespaces -->\n<Button />\n<!-- after -->\n<myui:Button xmlns:myui=\"using:Microsoft.UI.Xaml.Controls\" />","handlingStrategy":"validation","validationCode":"// Lint XAML for type names that resolve to >1 candidate before building\n// (tooling: run the XAML compiler in a dry parse pass and fail on ambiguity)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Qualify XAML types with an explicit xmlns prefix when multiple assemblies define the same name.","Avoid adding two PackageReferences that ship duplicate type names in overlapping namespaces."],"tags":["roslyn","xaml","type-resolution","ambiguous","source-generator"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}