Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Dialog messages that contain \r\n render the \r\n as text #977

Closed
mjjames opened this issue Jun 15, 2019 · 5 comments · Fixed by #1285
Closed

File Dialog messages that contain \r\n render the \r\n as text #977

mjjames opened this issue Jun 15, 2019 · 5 comments · Fixed by #1285
Assignees
Labels
Bug Product bug (most likely) rank20 Rank: Priority/rank on a scale of (1..100) regression status: This issue is a regression from a previous build or release
Milestone

Comments

@mjjames
Copy link

mjjames commented Jun 15, 2019

  • .NET Core Version: 3.0.0-preview6-27804-01
  • Windows version: Windows 10 Build 18917.rs_prerelease.190607-1942 and Windows 7 sp1
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No

Problem description:
When you use an Open File Dialog and provide an invalid file OR if you use a Save File Dialog and try to overwrite an existing file the messagebox renders the \r\n as text instead of a line break.

This happens if you use the Microsoft.Win32 base implementations or the System.Windows.Forms varients

Actual behavior:
image

Expected behavior:
image

Minimal repro:

var saveDialog = new Microsoft.Win32.SaveFileDialog
{
	OverwritePrompt = true
};
var success = saveDialog.ShowDialog();
var saveDialogForms = new System.Windows.Forms.SaveFileDialog
{
	OverwritePrompt = true
};
var successForms = saveDialog.ShowDialog();
@mjjames
Copy link
Author

mjjames commented Jun 15, 2019

Appears to just be an issue with the strings resource file All of the other resource strings just use \n however the file dialog ones still use the \r\n format

@weltkante
Copy link

This analysis/fix doesn't make sense. If \n would work then you'd see a line break after a literal \r

It might be worth digging deeper to find the actual bug (or add a link to the issue if you already know why this happens)

@rjvdboon
Copy link

I think the .resx files should not contain the literal \r\n, but have either xml encoded entities, or actual newline in the value. If so, the root cause is in the original creation of the .resx file.

Note that .Net framework sdk resgen.exe translates from .txt to .resx by replacing escape sequences with the actual value, i.e.
WithNewLine=Before\r\nAfter
is translated to

<data name="WithNewLine" xml:space="preserve">
    <value>Before
After</value>
  </data>

See also Resource text files

@grubioe grubioe added Bug Product bug (most likely) regression status: This issue is a regression from a previous build or release labels Jun 19, 2019
@grubioe grubioe added this to the 3.0 milestone Jun 19, 2019
@weltkante
Copy link

WinForms solved this in PR dotnet/winforms#1211 by replacing escape sequences with literal line breaks.

@RussKie
Copy link
Member

RussKie commented Jun 25, 2019

You may wish to sweep all your resources for \r\n sequence and replace them with hard line breaks.

@grubioe grubioe added the rank20 Rank: Priority/rank on a scale of (1..100) label Jul 16, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Apr 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Product bug (most likely) rank20 Rank: Priority/rank on a scale of (1..100) regression status: This issue is a regression from a previous build or release
Projects
None yet
6 participants