Search code examples
c#visual-studioresx

ResXFileCodeGenerator - overriding the output (want to use a Custom ResourceManager)


I've created a class the inherits from ResourceManager. My problem is that if I change my Resources.Designer.cs to use it,

e.g.

private static global::System.Resources.ResourceManager _resourceManager;

to

private static global::MyProject.Resources.MyResourceManager _resourceManager;

it gets overwritten by the ResXFileCodeGenerator and set back to the default System.Resources.ResourceManager.

I don't want to turn off the ResXFileCodeGenerator. But is there any way of telling it which ResourceManager class to use?

I was told to look at ResXFileCodeGeneratorEx but can't really see how that is any different in this respect.


Solution

  • I managed to achieve this using T4

    https://msdn.microsoft.com/en-us/library/bb126445.aspx

    Basically allows automatic code generation in the way that ResXFileCodeGenerator does.

    It's not a perfect solution though as it was a lot of work just to replicate the functionality of ResXFileCodeGenerator and also it doesn't automatically run every time the .resx file is saved without having to install another Visual Studio custom tool which I will have to give to get all the developers on the project to install.