Consider using resw file name as class name

Nov 13, 2012 at 9:36 PM
Edited Nov 13, 2012 at 9:36 PM

Thanks for this much-needed tool! My only issue with it so far is that it always creates a class named 'Resources', which often conflicts with properties named 'Resources', and I'd rather not have to qualify the namespace all of the time. I wonder if you could use the resw file name as the class name instead of always using 'Resources', e.g. 'AppResources.resw' generates 'AppResources.cs' with an 'AppResources' class instead of a 'Resources' class. Thanks for your consideration!

Nov 13, 2012 at 10:28 PM

Thanks for the input! I'll see what I can do :)

Nov 14, 2012 at 1:43 PM

I made the code changes necessary but the installer project is giving me trouble (I'm new to InstallShield)!

Anyway, I committed the latest source and you should be able to re-build it using Visual Studio 2012 (requires the Visual Studio 2012 SDK), the only problem is that the version number is not updated

Anyway, I'm gonna look at the issues in the installer tonight and hopefully publish a new build as well

Nov 16, 2012 at 10:18 PM

Thanks for the new installer! A few issues:

Bug: To access the resources in 'AppResources.resw', the ResourceLoader needs to be constructed like this: new ResourceLoader("AppResources"). Should be a simple fix. new ResourceLoader() always looks for 'Resources.resw' in the running app, even if it is missing.

Installer: Not a big deal at all, but I had to uninstall the old version before I could install the new version.

Windows Store apps definitely prefer the name 'Resources.resw'. 'ms-resource:StringName' always looks there, though I think you can redirect with 'ms-resource:///AppResources/StringName'.

There's probably no way to redirect the XAML resources (e.g. 'MyButtonId.Content') so I'll probably just stick with Resources.resw and use this to avoid naming conflicts: using AppResources = My.Namespace.Resources;

The best "documentation" is buried in this sample: Changing that sample to use your code generator might be a good way to test the different scenarios.

It looks like a resw file in a class library would have to be additionally qualified with the assembly name, e.g. new ResourceLoader("AssemblyName/ResourcesName"). I'm not sure how you'd support that with the code generator.

Thanks again!

Nov 19, 2012 at 11:53 AM

Thanks for the feedback and suggestions! I try using the MSDN sample for testing the next build. I can try to update the installer so that it would just install over the previous version, I can't promise this will come in the next build as InstallShield isn't exactly my cup of tea :)