dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.71k stars 1.06k forks source link

'\r' characters in resource string were stripped when being retrieved #5971

Open jeremymeng opened 8 years ago

jeremymeng commented 8 years ago

Steps to reproduce

Simplified repro: https://github.com/jeremymeng/resource-test.git

I have a resource file that is shared by a desktop project and a netcoreapp1.0 project. In the resource file there's a resource string that spans multiple lines. The projects simply print out the resource string.

Expected behavior

Both projects print out

1\r\n2\r\n3

Actual behavior

netcoreapp1.0 project prints out 1\n2\n3, with '\r' removed.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc2-002617)

Product Information: Version: 1.0.0-rc2-002617 Commit Sha: db89bd35fc

Runtime Environment: OS Name: Windows OS Version: 10.0.10586 OS Platform: Windows RID: win10-x64

svick commented 8 years ago

Have you tried running program using dotnet <path-to-your-program>.dll instead of dotnet run?

(Where the path is probably something like bin\Debug\netcoreapp1.0\.)

And how exactly do you figure out whether it prints \r or not?

jeremymeng commented 8 years ago

Have you tried running program using dotnet .dll instead of dotnet run?

Same result.

And how exactly do you figure out whether it prints \r or not?

I just print "\\r" if the character is \r. Anyway, the project is just a simplified repro. What I really had was failing unit tests that expect "\r\n", as on Desktop, but end up without "\r" in the retrieved string. Under debugger on .NET Core, the result from ResourceManager.GetString(...) does not contain "\r" (https://github.com/jeremymeng/resource-test/blob/master/src/Console-Desktop/Resource1.Designer.cs#L71).

TheRealPiotrP commented 8 years ago

@jeremymeng if you've already found that ResourceManager.GetString() does not contain the '\r' then can we move this bug over to https://github.com/dotnet/corefx?

jeremymeng commented 8 years ago

@piotrpMSFT we haven't ruled out the possibility of the difference in embedding resource strings. ILDasm shows the length of the embedded resource is exactly two less in the netcoreapp1.0 dll.

.mresource public Console_Desktop.Resource1.resources
{
  // Offset: 0x00000000 Length: 0x000000E3
}

In the desktop executable, the length is 0xE5.