Repository navigation
Description
Current behavior 🐛
Severity: Low - code that compares or splits TextBlock.Text sees a different string than on WinUI (\n instead of \r\n); nothing crashes and nothing renders wrong.
When a TextBlock is built from inlines, Text reports each <LineBreak/> as "\n":
<TextBlock>Line1<LineBreak/>Line2<LineBreak/><LineBreak/>Line4</TextBlock>Text is "Line1\nLine2\n\nLine4" on Uno.
Expected behavior 🎯
On WinUI, Text is "Line1\r\nLine2\r\n\r\nLine4". Each LineBreak reads back as "\r\n".
How to reproduce it (as minimally and precisely as possible) 🔬
- Create an app with a page containing the XAML above, named
tb. - After it loads, read
tb.Textand print it with\r/\nescaped (e.g.tb.Text.Replace("\r", "\r").Replace("\n", "\n")). - Uno Skia desktop prints
Line1\nLine2\n\nLine4. WinUI 3 printsLine1\r\nLine2\r\n\r\nLine4.
A Text that contains a literal LF reads back unchanged on both, so only the inline-built path differs.
Workaround 🛠️
Normalize line endings when reading Text, e.g. tb.Text.Replace("\r\n", "\n").
Works on UWP/WinUI
Yes (\r\n).
Affected platforms 📱💻🖥️
Skia Desktop (Win32). The shared code is not platform-specific, so other Skia heads are likely affected too (not tested).
Uno.Sdk version (and other relevant versions) 📦
Uno master 4636b705e97 (2026-11-12), net11.0-desktop, .NET SDK 11.0.100. InlineExtensions.cs has not changed on master since (git log 4636b705e97..origin/master is empty for it).
Anything else we need to know? 💬
What was verified
- Runtime on Uno: a prebuilt Release SamplesApp of
4636b705e97, Skia desktop, re-run on 2026-11-13. It printed"Line1\nLine2\n\nLine4". - Runtime on WinUI: the same probe on a WinUI 3 app (WinAppSDK 2.5.1) printed
"Line1\r\nLine2\r\n\r\nLine4".
Root cause
InlineExtensions.GetText returns "\n" for a LineBreak. TextBlock uses it to build _inlinesText and then Text.
Careful with the fix
GetText is also the flat character index space for layout: ParsedText assumes a LineBreak is exactly one character, and ParagraphTextSource, UnicodeText, MathTextLayout and the RichTextBlock offset code also use its lengths. Changing it to "\r\n" would shift every offset after a LineBreak by one (selection, hit testing, text pointers). A safer fix is probably what RichTextBlock already does in GetPlainTextOf: keep GetText for layout and build the public Text with "\r\n" separately.
Related but different bug: #26148 (CR and LF in different inlines make one line break instead of two).
Activity
ZainnQureshii commentedon Nov 23, 2026
Hi, could you assign this one to me? I reproduced it in Uno's unit tests on macOS and I have a fix ready that returns CRLF for an explicit LineBreak, with a regression test that also checks the selection after the break.