question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

String resource containing only whitespace characters are loaded as blank strings

See original GitHub issue

.NET version

Replicated on .NET Core 3 and all later versions.

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

I did not try this with versions prior to .NET Core 3.

Issue description

If a localized property’s value is set to a string that only contains whitespace characters, ComponentResourceManager methods such as ApplyResources or GetString retrieve it as a blank string. This is a breaking change for .NET Framework applications where this is not the case.

I could not find this change documented anywhere, or any issues related to it.

The XML generated for the property is the same in both .NET FX and .NET Core/5+:

<data name="label1.Text" xml:space="preserve">
  <value>  </value>
</data>

Steps to reproduce

I attached a solution containing two identical forms in .NET Framework 4.8 and .NET 6. T1080450.zip

To replicate:

  • Create a new project using the Windows Forms App template.
  • Set the main form’s Localizable property to true.
  • Add a label and set its Text property to (a string with a single whitespace character).
  • Debug the project and check the value of this property after it is set in the InitializeComponent method.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
TheLeftExitcommented, Apr 23, 2022

I guess that’s a wrap. Thanks @kant2002!

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - How to keep the spaces at the end and/or ...
I wanted to leave a blank at the end of a resource string ... I just use the UTF code for space "\u0020"...
Read more >
ResourceManager.GetString() returns "" when value only ...
It worked fine when I added a non-space character to the value, but . ... String resource containing only whitespace characters are loaded...
Read more >
Remove useless whitespace from styled string
The answer is to put the newlines at the start of each line, directly before the text. <string name="about_text"><big><b>About</b></big> ...
Read more >
Checking for Empty or Blank Strings in Java
If a string only consists of whitespace, then we call it blank. For Java, whitespaces are characters, like spaces, tabs, and so on....
Read more >
Program to Check if String is Empty in Python
A blank string contains whitespaces while an empty string does not contain any characters or whitespace. The method where White spaces in strings...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found