Skip to content

Comments

ResX provider: create resource manager directly without needing VS studio or resgen to generate designer files#337

Open
tracerco-peter wants to merge 4 commits intoXAMLMarkupExtensions:masterfrom
tracerco-peter:master
Open

ResX provider: create resource manager directly without needing VS studio or resgen to generate designer files#337
tracerco-peter wants to merge 4 commits intoXAMLMarkupExtensions:masterfrom
tracerco-peter:master

Conversation

@tracerco-peter
Copy link

@tracerco-peter tracerco-peter commented Jan 18, 2022

In an application I am working on my team have created a tool to extract localizable xaml properties and generate resx files automatically. The issue we have is that our tool is generating the resx files outside of Visual Studio. This means that the ResXFileCodeGenerator custom tool is not executed by Visual Studio (unless we run Resgen.exe manually or open each of the generated files in Visual Studio).

The library is making an assumption that the strongly-typed resource class (generated by ResXFileCodeGenerator custom tool in VS or by Resgen.exe) will exist. The assembly will still contains the actual .resources file despite these tools not being ran but the library will not load the resources, as the type can't be found. From the assembly name and dictionary name we can attempt to create a new resource manager manually by assuming that if if we have a .resources file embedded in the assembly which matches the assembly name + dictionary name then we can attempt to manually create an instance of it.

… (addresses an issue where resource classes are not created).
@CLAassistant
Copy link

CLAassistant commented Jan 18, 2022

CLA assistant check
All committers have signed the CLA.

@konne
Copy link
Member

konne commented Jan 19, 2022

@tracerco-peter can you please also attach a simple translated "Hello World" application in the tests folder.
That uses your workflow. So that I can better check and understand how you like to use it.

@tracerco-peter
Copy link
Author

added HelloWorld.NoDesignerFiles test. It's a copy of the original project with the designer.cs files removed and the 'ResXFileCodeGenerator' custom action removed from the Ressourcen.resx (to prevent VS from generating them again)

@BhaaLseN
Copy link

I was just about to write code myself, but then I found this MR. Is there anything blocking this from getting merged (and, ultimately, released through NuGet at some point)?

I'm not running ResXFileCodeGenerator on any of my RESX files because I usually use the ResourceManager directly to pull resources using resource keys (and I don't really need an extra strongly typed class generated around it with numerous members nobody is going to use).
My current workaround to get this to cooperate with ResxLocalizationProviderBase is to create a dummy class with a ResourceManager property, which I'd also like to get rid of at some point.

@konne
Copy link
Member

konne commented Aug 6, 2024

@tracerco-peter @BhaaLseN sorry I was the last moths very busy with other topcis. I will follow up

@konne
Copy link
Member

konne commented Aug 6, 2024

@Karnah the PR LGTM, can you please review from your side, if you spot any risks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants