title: IStringLocalizer doesn't work when setting Custom Tool Namespace property of the resx file
body: <p>We are using .net5 in our solution. we want to place all resources (.resx) files in separated class library project. As you can see in below image, there are many classes that each of them has its specified folder containing a main .resx file for default culture and some other files for other cultures and of course the designer class.</p>
  <p><a href="https://i.stack.imgur.com/7B0hV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7B0hV.png" alt="enter image description here" /></a></p>
  <p>By setting the &quot;Custom Tool&quot; property of each resx file to &quot;PublicResXFileCodeGenerator&quot; we make the designer classes available throughout the solution:</p>
  <p><a href="https://i.stack.imgur.com/YovVW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YovVW.png" alt="enter image description here" /></a></p>
  <p>a) DataAnnotations:</p>
  <p>Using the designer class is possible easily in dataAnnotations. for example for Required attribute we can decorate intended property with an attribute like this:</p>
  <pre><code>[Required(ErrorMessageResourceType = typeof(Infrastructure.ResourceManager.Resources.Media.Media) , ErrorMessageResourceName = &quot;SomeKey&quot;)]
  </code></pre>
  <p>b) static ResourceManager property:</p>
  <p>Also anywhere in the project we can access the resources and get localized string with a code like this:</p>
  <pre><code>Infrastructure.ResourceManager.Resources.Media.Media.ResourceManager.GetString(&quot;SomeKey&quot;);
  </code></pre>
  <p>c) IStringLocalizer:</p>
  <p>Finally we can inject IStringLocalizer in for example our controllers and use it like this:</p>
  <pre><code>public class TestController : ControllerBase
  {
      
      private readonly IStringLocalizer&lt;Infrastructure.ResourceManager.Resources.Media.Media&gt; _mediaLocalizer;
     
      public TestController(IStringLocalizer&lt;Infrastructure.ResourceManager.Resources.Media.Media&gt; mediaLocalizer)
      {
          _mediaLocalizer = mediaLocalizer;
      }
      public string GetLocalizedString(string someKey)
      {
          return _mediaLocalizer[someKey];
      }
  }
  </code></pre>
  <p>d) The problem:</p>
  <p>everything explained above work fine. however we need to change the namespace of resx-file's designer class. in fact having folder and class with same name makes our code a kind of ugly repeat!
  we can do this by changing the &quot;Custom Tool Namespace&quot; property of resx file. but after that IStringLocalizer will not work anymore. I found <a href="https://stackoverflow.com/questions/41039722/resource-files-resx-does-not-respect-custom-tool-namespace">this post</a> containing similar problem but solutions do not help. can anybody give me a solution and explanation of why this happen?</p>