none
Need macro or tool to automatialy change internal .ctor to public in resource files.

    Question

  • I know a lot of people have this problem but I haven't found any solution and I would think that by now a tool or workaround would have been developed for this. When using resource files for strings to be consumed by xaml, its necessary to change the resource file's constructor from internal to public.  changing the designer's access modifier from internal to public doesn't do it.  a long time ago I wrote a macro to do this (before VS did away with macros) but it was a real pain to develop.  Now that VS doesn't support macros anymore, I lost the code for that.  our projects have 100s of resource files which are frequently updated by a codegen tool.  after running the codege, we have to:

    1) Manually toggle the Access Modifier from public, to internal (or No code generation) and back to public to update all the code-behind, and then

    2) edit the code behind changing internal to public.

    this is always a laborious 2-step process for every file modified.

    Does anyone have a good idea for a workaround on this?


    • Edited by moondaddy Thursday, September 22, 2016 2:40 AM forgot a comment
    Wednesday, September 21, 2016 11:08 PM

Answers

  • Hi moondaddy,

    The  ResXManager extension for Visual Studio will list all resource files in all folders, include the subfolder. And it manager the resource also through by right-click on the extension UI, not a command, which is more easier.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 23, 2016 1:58 AM
    Moderator

All replies

  • I found a solution that does part of what I need.

    https://sites.google.com/site/dmytrokryvko/

    Its a VS Extension which make it public instead of internal.  Also, when my codegen tool make the resx files for the first time and I "Include" them into the solution, the code behind is automatically created.  Great.

    However, if I regen the resx file with some additional strings, the code behind is not automatically updated.  I have to manually open the resx file and save it, which is still less work than anything I did  before, but its not completely hands off yet.

    I would still like to find a tool that would update all resx files in a folder and its subfolders.

    Thursday, September 22, 2016 4:27 AM
  • Hi moondaddy,

    According to your description, you want to batch modify your Resources files in your project from public to internal and from internal to public, is it right?

    Please try use ResXManager extension for Visual Studio, which will list all resource files in your project and then you could manager them as following screenshot to modify the access way.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 22, 2016 6:30 AM
    Moderator
  • Hi Weiwei, thanks for the followup.  There are 2 things that must happen after the codegen tool has updated the strings:

    1)  regen the code behind so its in sync with the new strings

    2) convert internal to public.

    I have achieved this by installing these 2 tools

    Extended Strongly Typed Resource Generator
    https://sites.google.com/site/dmytrokryvko/

    and

    AutoRunCustomTo​

    https://visualstudiogallery.msdn.microsoft.com/ecb123bf-44bb-4ae3-91ee-a08fc1b9770e

    which will sync the files with a right click action shown in the screenshot.

    Currently I can run this right click action on multiple files by selecting multiple files as shown in the screenshot (similar to your screenshot).

    What I want to do is to do this to a folder(s) and have the command run on all resx files in the folder(s).  Even better would to also run on all files in all subfolders.

    Thank you.

    Thursday, September 22, 2016 12:30 PM
  • Hi moondaddy,

    The  ResXManager extension for Visual Studio will list all resource files in all folders, include the subfolder. And it manager the resource also through by right-click on the extension UI, not a command, which is more easier.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 23, 2016 1:58 AM
    Moderator
  • Thank you for all the help in this thread.  Its been a while since I posted here.  The tool mentioned above works really good for converting resource files from internal to public which is needed to reference their properties from c#:

    Extended Strongly Typed Resource Generator
    https://sites.google.com/site/dmytrokryvko/

    However, this tool was created a long time ago and only works for VS 2013.  Is there a tool that can do the same thing for VS 2015?

    Thank you

    OK, I found the tool.  go to this site to get the one upgraded for vs 2015

    https://marketplace.visualstudio.com/items?itemName=Paruz.ExtendedStronglyTypedResourceGenerator

    • Edited by moondaddy Saturday, April 15, 2017 6:30 PM forgot
    Saturday, April 15, 2017 6:17 PM