dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.75k forks source link

Editor control on Windows uses CR as line ending #24361

Closed andrekoehler closed 1 month ago

andrekoehler commented 2 months ago

Description

When I enter two lines of text into an Editor control like this one: <Editor Text="{Binding SomeString}" /> SomeString will use a single CR (0x0D) as the line separator. On my Windows machine. I expected Environment.NewLine (== CR LF) or LF, but not CR, which should only ever be used on MacOS.

Running on German Windows 11 23H2

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.80 SR8

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

net8.0-windows10.0.19041.0

Did you find any workaround?

Use a value converter for the string binding to replace the line endings:

class LineBreakConverter : IValueConverter
{
    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is string crlf)
        {
            return crlf.ReplaceLineEndings("\r");
        }
        return value;
    }

    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is string cr)
        {
            return cr.ReplaceLineEndings();
        }
        return value;
    }
}

Relevant log output

No response

ninachen03 commented 2 months ago

Could you provide us with a sample project so we can investigate it further? Looking forward to your reply!

dotnet-policy-service[bot] commented 1 month ago

Hi @andrekoehler. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

jfversluis commented 1 month ago

Could you please show us how you update the value? Are you sure there are no "weird" line endings in the text that you try to set it to?

dotnet-policy-service[bot] commented 1 month ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.