Skip to content

XamlCompiler does not provide enough information to locate XML parse errors #7367

@jamers99

Description

@jamers99

Describe the bug

We're migrating from UWP to WinUI and a few of our files didn't have the following code in the .xaml.

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

If you remove them, it fails...

Task "CompileXaml"
1>    Xaml Compiler Marker: 9:03:58:  20 perfXC_StartPass1, General.WinUI
1>    Xaml Compiler Marker: 9:03:58:  73 perfXC_FingerprintCheck, Differ: c:\repos\eagle\framework\client\eagle.client.winui\bin\debug\net6.0-windows10.0.19041.0\eagle.client.winui.dll
1>    Xaml Compiler Marker: 9:03:58:  81 perfXC_FingerprintCheck, Reference Assemblies Fingerprint Changed
1>    Xaml Compiler Marker: 9:03:58:  81 perfXC_CreatingTypeUniverse
1>    Xaml Compiler Marker: 9:03:58:  81 perfXC_CreatedTypeUniverse
1>    Xaml Compiler Marker: 9:03:58:  81 perfXC_CreatingSchemaContext
1>    Xaml Compiler Marker: 9:03:58: 159 perfXC_InitializeTypeNameMapStart
1>    Xaml Compiler Marker: 9:03:59: 128 perfXC_InitializeTypeNameMapEnd
1>    Xaml Compiler Marker: 9:03:59: 157 perfXC_CreatedSchemaContext
1>    C:\Users\james\.nuget\packages\microsoft.windowsappsdk\1.0.3\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(475,9): Xaml Internal Error error WMC9999: 'd' is an undeclared prefix. Line 6, position 14.
1>       at System.Xml.XmlTextReaderImpl.Throw(Exception e)
1>       at System.Xml.XmlTextReaderImpl.LookupNamespace(NodeData node)
1>       at System.Xml.XmlTextReaderImpl.AttributeNamespaceLookup()
1>       at System.Xml.XmlTextReaderImpl.ParseAttributes()
1>       at System.Xml.XmlTextReaderImpl.ParseElement()
1>       at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
1>       at System.Xaml.XmlCompatibilityReader.Read()
1>       at MS.Internal.Xaml.Parser.XamlScanner.DoXmlRead()
1>       at MS.Internal.Xaml.Parser.XamlPullParser.<Parse>d__4.MoveNext()
1>       at MS.Internal.Xaml.NodeStreamSorter.StartNewNodeStreamWithSettingsPreamble()
1>       at MS.Internal.Xaml.NodeStreamSorter..ctor(XamlParserContext context, XamlPullParser parser, XamlXmlReaderSettings settings, Dictionary`2 xmlnsDictionary)
1>       at System.Xaml.XamlXmlReader.Initialize(XmlReader givenXmlReader, XamlSchemaContext schemaContext, XamlXmlReaderSettings settings)
1>       at Microsoft.UI.Xaml.Markup.Compiler.Utilities.XamlNodeStreamHelper.ReadXClassFromXamlFileStream(TextReader fileStream, XamlSchemaContext schemaContext)
1>       at Microsoft.UI.Xaml.Markup.Compiler.SourceFileManager.PropagateOutOfDateStatus(DirectUISchemaContext context)
1>       at Microsoft.UI.Xaml.Markup.Compiler.CompileXamlInternal.DoExecute()
1>    Xaml Compiler Marker: 9:04:00:  27 perfXC_EndPass1, General.WinUI
1>  Done executing task "CompileXaml" -- FAILED.

But it gives no indication of where the issue is. When there is a project with 60+ xaml files, it's incredibly tedious to find where the issue is. I actually wrote a regex to find it :D

Steps to reproduce the bug

Download and build this simple project that has the line removed (don't open the xaml file).
App1.zip

Expected behavior

It should give the file that the error is in and when double clicking the error, take me to the proper line.

Screenshots

image

NuGet package version

WinUI 3 - Windows App SDK 1.0.4

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 11 (21H2): Build 22000

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions