Getting NULL when using ResourceManager.GetString() with strings using placeholders
See original GitHub issueI have a embedded Resource.resx file and a Resource.Designer.cs autogenerated containing many string resources, some of them have placeholders (i.e. “Hello, ‘{0}’”) and these are the ones that are returning null when calling from code, i.e. Resource.KeyName. This Resource.resx file exist in a library project with TargetFrameworks net452, netstandard2.0 and netstandard2.1. I’m dealing with this issue when I run my Test Project (net452, netcoreapp3.0, netcoreapp2.2) and make use of that Resource.
This issue is only happening when the tests are ran using net452 (I have tried with net472 also and behaves the same) with resources containing placeholders and compiling/running tests from CLI (dotnet test), when using VS it’s working fine. I had to add the following to my .csproj of the library because it was failing at compiling:
<GenerateResourceUsePreserializedResources>**true**</GenerateResourceUsePreserializedResources>
<PackageReference Include="System.Resources.Extensions">
<Version>4.6.0-preview8.19405.3</Version>
</PackageReference>
SDK used: 3.0.100-preview8-013656
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (7 by maintainers)
Top GitHub Comments
Thanks @danielValdezR! The fact that the second build is required is indicative of microsoft/msbuild#4553. I tried your repro on my machine with a preview9 build (
3.0.100-preview9-014004
) and all three TargetFrameworks pass tests. Another change means thatSystem.Resources.Extensions
is not required as often, so this specific repro project doesn’t require it, though that won’t be true of all.resx
files.I’m going to close this based on my results. If you see further bad behavior after updating to preview 9, please comment again and we can reopen and investigate.
repro project: https://github.com/danielValdezR/ResourcesTest
Steps to reproduce: cd …\ResourcesTest\ResourcesTest.Tests
Log: https://github.com/danielValdezR/ResourcesTest/blob/master/log.txt