{"record":{"id":"da64cb132485fc43","repo":"unoplatform/uno","slug":"unable-to-find-type-fullyqualifiedname","errorCode":null,"errorMessage":"Unable to find type {fullyQualifiedName}","messagePattern":"Unable to find type (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs","lineNumber":375,"sourceCode":"\t\t\tWindowSymbol = GetOptionalSymbolAsLazy(XamlConstants.Types.Window);\n\t\t\tApplicationSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.Application);\n\t\t\tResourceDictionarySymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.ResourceDictionary);\n\t\t\tTextBlockSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.TextBlock);\n\t\t\tRunSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.Run);\n\t\t\tSpanSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.Span);\n\t\t\tBorderSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.Border);\n\t\t\tSolidColorBrushSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.SolidColorBrush);\n\t\t\tRowDefinitionSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.RowDefinition);\n\t\t\tColumnDefinitionSymbol = GetMandatorySymbolAsLazy(XamlConstants.Types.ColumnDefinition);\n\t\t\tTaskSymbol = GetMandatorySymbolAsLazy(\"System.Threading.Tasks\");\n\n\t\t\tTypeProviders = ImmutableArray.Create<ITypeProvider>(\n\t\t\t\tnew MvvmTypeProvider(this)\n\t\t\t\t);\n\t\t}\n\n\t\tprivate Lazy<INamedTypeSymbol> GetMandatorySymbolAsLazy(string fullyQualifiedName)\n\t\t\t=> new(() => _generatorContext.Compilation.GetTypeByMetadataName(fullyQualifiedName) ?? throw new InvalidOperationException($\"Unable to find type {fullyQualifiedName}\"));\n\n\t\tinternal Lazy<INamedTypeSymbol?> GetOptionalSymbolAsLazy(string fullyQualifiedName)\n\t\t\t=> new(() => _generatorContext.Compilation.GetTypeByMetadataName(fullyQualifiedName));\n\n\t\tprivate Lazy<INamedTypeSymbol> GetSpecialTypeSymbolAsLazy(SpecialType specialType)\n\t\t\t=> new(() => _generatorContext.Compilation.GetSpecialType(specialType));\n\n\t\tprivate static bool IsWinUIItem(Uno.Roslyn.MSBuildItem item)\n\t\t\t=> item.GetMetadataValue(\"XamlRuntime\") is { } xamlRuntime\n\t\t\t\t? xamlRuntime == \"WinUI\" || string.IsNullOrWhiteSpace(xamlRuntime)\n\t\t\t\t: true;\n\n\t\tprivate IEnumerable<Uno.Roslyn.MSBuildItem> GetWinUIItems(string name)\n\t\t\t=> _generatorContext.GetMSBuildItemsWithAdditionalFiles(name).Where(IsWinUIItem);\n\n\t\t/// <summary>\n\t\t/// Get the file location as seen in the IDE, used for ResourceDictionary.Source resolution.\n\t\t/// </summary>","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs#L357-L393","documentation":"Thrown (lazily) by GetMandatorySymbolAsLazy when Compilation.GetTypeByMetadataName returns null for a type that the XAML generator considers mandatory — including Border, SolidColorBrush, RowDefinition, ColumnDefinition, and System.Threading.Tasks.Task. The Lazy is only evaluated when the symbol is first accessed.","triggerScenarios":"The Roslyn compilation used by the source generator does not include a reference to the assembly that defines one of the mandatory types. For example, if Uno.UI or the WinUI reference assembly providing Border/SolidColorBrush is not referenced.","commonSituations":"A project references Uno.UI NuGet packages incorrectly or uses incompatible versions; the compilation is missing the WinUI/Uno type-forwarding assembly; package downgrade or restore failure left required assemblies unresolvable.","solutions":["Verify that the project references the correct Uno.UI (and related) NuGet packages with compatible versions.","Run dotnet restore to ensure all packages are properly restored.","Check for version mismatches between Uno.UI, Uno.WinUI, and the target framework packages.","If the error names a specific type, ensure the assembly defining that type is referenced."],"exampleFix":"<!-- Ensure correct package references in .csproj -->\n<ItemGroup>\n  <PackageReference Include=\"Uno.UI\" Version=\"5.x.x\" />\n  <PackageReference Include=\"Uno.WinUI\" Version=\"5.x.x\" />\n</ItemGroup>","handlingStrategy":"validation","validationCode":"<!-- Verify mandatory type-providing packages are referenced -->\n<ItemGroup>\n  <PackageReference Include=\"Uno.WinUI\" Version=\"$(UnoVersion)\" />\n  <PackageReference Include=\"Uno.UI\" Version=\"$(UnoVersion)\" />\n</ItemGroup>\n<!-- After editing, run: dotnet restore && dotnet build -->","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep Uno.UI / Uno.WinUI package versions aligned across all projects.","Run dotnet restore after changing package references.","Check for package downgrade warnings that may cause type resolution failures."],"tags":["type-resolution","compilation","source-generator","references"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}