Search code examples
.net-coremauimaui-windows

Is MAUI Label for TextType as Html using an XML parser on Windows?


The documentation for the MAUI Label control and its TextType property says about the type Html support in https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/label?view=net-maui-7.0:

Displaying HTML in a Label is limited to the HTML tags that are supported by the underlying platform.

It doesn't tell what is supposed to happen if some "tags" are not supported on a platform. I see a crash of the complete MAUI application under Windows with some (as I would think) harmless p "tags" i.e. the following crashes for me on Windows:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiLabelTextTypeHtmlTests.MainPage">

    <ScrollView>
        <VerticalStackLayout
            Spacing="25"
            Padding="30,0"
            VerticalOptions="Center">

            <Label TextType="Html"><![CDATA[<p>This is paragraph 1.<p>This is paragraph 2.]]></Label>

        </VerticalStackLayout>
    </ScrollView>

</ContentPage>

Is a crash the expected result if the Label control can't handle the HTML "tags"?

Why does it crash?

The remaining output console lines show a loading of XDocument, is the Label control on Windows trying to parse HTML "tags" as well-formed XML and crashes off if the HTML tags do not obey XML well-formedness rules?

The sample renders fine as two lines/paragraphs of text with MAUI under Android.

A sample output in the debug output pane for a run with above sample markup (the app window never shows up at all) is e.g.

'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: DefaultDomain): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\MauiLabelTextTypeHtmlTests.dll'. Symbols loaded.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\WinRT.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Runtime.InteropServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Collections.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Collections.Concurrent.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.WinUI.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Runtime.CompilerServices.Unsafe.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Private.Uri.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.ObjectModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.ComponentModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Numerics.Vectors.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Windows.SDK.NET.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Security.Cryptography.Algorithms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Security.Cryptography.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Security.Cryptography.Csp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Security.Cryptography.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.InteractiveExperiences.Projection.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.Controls.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.DependencyInjection.Abstractions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.Essentials.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.Controls.Xaml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.Logging.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.Logging.Debug.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.Configuration.Abstractions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Xml.ReaderWriter.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Private.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.Graphics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Net.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.Logging.Abstractions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.ComponentModel.TypeConverter.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.Graphics.Win2D.WinUI.Desktop.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.Options.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.DependencyInjection.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Diagnostics.Tracing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Threading.ThreadPool.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Memory.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Linq.Expressions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Reflection.Emit.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'Snippets'. 
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.Controls.Compatibility.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Reflection.Emit.Lightweight.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Reflection.Emit.ILGeneration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Reflection.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Runtime.Loader.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Text.RegularExpressions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Xml.XDocument.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Private.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Threading.Thread.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Diagnostics.StackTrace.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Reflection.Metadata.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Collections.Immutable.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[33576] MauiLabelTextTypeHtmlTests.exe' has exited with code 0 (0x0).

The debug output pane for e.g. the Label <Label TextType="Html"><![CDATA[<p>This is line 1.<br>This is line 2.<br>This is line 3.</p>]]></Label> shows the following:

'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: DefaultDomain): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\MauiLabelTextTypeHtmlTests.dll'. Symbols loaded.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\WinRT.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Runtime.InteropServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Collections.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Collections.Concurrent.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.WinUI.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Runtime.CompilerServices.Unsafe.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Private.Uri.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.ObjectModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.ComponentModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Numerics.Vectors.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Windows.SDK.NET.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Security.Cryptography.Algorithms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Security.Cryptography.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Security.Cryptography.Csp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Security.Cryptography.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.InteractiveExperiences.Projection.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.Controls.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.DependencyInjection.Abstractions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.Essentials.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Maui.Controls.Xaml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.Logging.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.Logging.Debug.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiLabelTextTypeHtmlTests.exe' (CoreCLR: clrhost): Loaded 'C:\Users\marti\Source\Repos\martin-honnen\MauiLabelTextTypeHtmlTests\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Extensions.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

Solution

  • I think I have found the relevant code in https://github.com/dotnet/maui/blob/17790124c566d73001761ea93a447876e4ed0b90/src/Core/src/Platform/Windows/TextBlockExtensions.cs#L101, it first seems to wrap the HTML fragment text into a div element with e.g. var modifiedText = string.Format("<div>{0}</div>", text);, then indeed does some cosmetic regular expression replacement to be able to deal with HTML <br> tag syntax in modifiedText = Regex.Replace(modifiedText, "<br>", "<br></br>", RegexOptions.IgnoreCase); (which explains why my br sample worked) and finally indeed throws the modified HTML at an XML parser with e.g. var element = XElement.Parse(modifiedText);.

    So for some strange reasons in 2022 with HTML5 and text/html being the established parsing approach for HTML for more than a decade, MAUI under Windows thinks an XML parser is adequate for HTML parsing.

    Still need to figure why nothing is rendered and the app crashes/does not appear/disappears (depending on when/where you set your HTML text) as the code at least seems to want to fall back on some normal rendering of text with e.g.

            try
            {
                var element = XElement.Parse(modifiedText);
                LabelHtmlHelper.ParseText(element, platformControl.Inlines, label);
            }
            catch (Exception)
            {
                // If anything goes wrong just show the html
                platformControl.Text = global::Windows.Data.Html.HtmlUtilities.ConvertToText(label.Text);
            }