Move to resource - Suggestion (v. 5)

Hi,

I would like to suggest a slight modification to the Move to resource dialog.

1. The comment field should have more than one line since we usually also have comments to the string.Format placeholders.
Example:

String: "The Table {0} cannot be modified by the user {1}"
Comment:     
{0}: the system table name
{1}: the user name
Messagebox for user with missing privileges.

For the given example it might be clear what the placeholder will contain. For more complex sentence it might not be possible for Localisation teams to know what this is for.

2. I asume I'm asking to match if R# would already create the entries for {0} and {1} so I could just fill in the comments for this placeholders.

3. I would also love to have a action which removes a resource from the resources and replaces the usage with the original string
     This way I don't have to open the resources to change either the Resource Name or the the Resource Text afterwards

BTW: I have a own Custom Tool to create the designer file for Resources. This Custom tool also declares the Resource.Property with [JetBrains.Annotations.NotNull]. It seems the R# still shows the action to verify whether the Resource.Property is null.

Regards
Martyn

31 comments

Hi, Martyn

Thank you for this great feedback.

1. The comment field should have more than one line since we usually also have comments to the string.Format placeholders.
Example:

String: "The Table {0} cannot be modified by the user {1}"
Comment:     
{0}: the system table name
{1}: the user name
Messagebox for user with missing privileges.

I will fix it ASAP.

3. I would also love to have a action which removes a resource from the resources and replaces the usage with the original string
     This way I don't have to open the resources to change either the Resource Name or the the Resource Text afterwards


For removing resource use "Inline" refactoring.
R# also have LITE resource editor. For using it you could bind key to the command  ReSharper_EditResourceValue. Please, try to use it.

BTW: I have a own Custom Tool to create the designer file for Resources. This Custom tool also declares the Resource.Property with [JetBrains.Annotations.NotNull]. It seems the R# still shows the action to verify whether the Resource.Property is null.

Do you see warning "Possible NRE" with Quick Fix or only action for checking property on null?

0

Hi,

I will fix it ASAP.

Great to hear.

For removing resource use "Inline" refactoring.
R# also have LITE resource editor. For using it you could bind key to the command  ReSharper_EditResourceValue. Please, try to use it.

Nice the refactoring of the existing resources, didn't see it . Thanks for the hint

Resource Refactoring is a little bit slow for some reason. The designer file has about 9000 lines. Maybe this is a reason. Moving a string to the resources or the inline operation takes a moment. The progressbar is standing a moment on "Run custom tool". When I run the custom tool manually, it takes about 2 sec. Using ResourceRefactoring from VS PowerToys takes around 5 sec without any modification. R# needs more than a minute. I hope you can improve this. Or does the solution wide analysis has to be enabled?

Do you see warning "Possible NRE" with Quick Fix or only action for checking property on null?


You are right, it is an action to check for null, my fault. I was just confused since it is marked NotNull.

Thanks for the quick response and your help.

Regards
Martyn

0

I need resx and designer file for investigation. Can you post in the forum or send me by email?

0

There are nice old Resource Refactoring Tool at CodePlex: http://www.codeplex.com/ResourceRefactoring. While new action mimics its functionality and can used instead maybe you find useful original functionality, for example: preview feature and handy similar strings dialog and implement in new action.

0

This is the tool we are currently using (see my previous posts in this thread). I also have modified it so we can add comments (somthing what is missing in the original implementation). But since R# will provide this functionality, it would be good if it is at least so good and so fast like the ResourceRefactor. I hope you agree.

The good thing of R# is, that he points me out strings which needs to be moved to the resources, what is very helpfull in a bigger project. Something the ResourceRefactor can't.

Thanks anyway for the hint.

0

Hello Nick,

Thank you for this message. We known about this tool.
The refactoring preview feature is not for 5.0.

Best regards,
Alexander Nesterenko
ReSharper developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


0

We optimized "Move to resource".  Please try to use last nightly build.

0

Hi,

I'm impressed, you imrpoved the performance 100x. I would say, the performance is now satisfying.

Any chance to have a spezial support for string.Format (adding the placehoders to the comment), and to customize the Resource Name?

Regards
Martyn

0

Hm... with our custom tool and a string containing {0} I just get a null reference exception (RSRP126764 I logged a second with additional information).

0

Thank you for this bug report. Can i see code provided by your custom tool?

0

The template for Resource Name you could find at the ReSharper | Options | Localization.

0

I see, thanks for the hint.

I found a new bug in this case . When I change the "name" template and select another node "Code Cleanup" and switch back.. my changes are lost.

Martyn

0

Ialready send you some generated code. Check your mail related to this thread.

0

I like your new "Move to resource" tool. But it should recognize, when a string is something like a variable. I.E: item["Code"]. Here the string "Code" should not be localizable ;-)

Or did I missed something?

0

Hi,
I also asked this kind of question .
Check this thread for the answer.
http://www.jetbrains.net/devnet/message/5248011

Martyn

0

Martyn, thanks for this information. I suppose, there is no other solution :-(

0

Hi.

1.) We have several resource files in a project and each time you do "Move to resource" the first one is selected.
We would like to see the last used resource file preselected so we can move multiple strings to a specific resource file much faster.

2.) Is it possible to move the string to a new resource file?

3.) Is it possible to get a list of all string wich are candidates for "Move to resource file"?
Currently we set it from Warning to Error to find the strings faster^^

4.) Thanks for this really helpfull feature =)

Regards,
Sven

0

1.) We have several resource files in a project and each time you do "Move to resource" the first one is selected.
We would like to see the last used resource file preselected so we can move multiple strings to a specific resource file much faster.

it will be available in the next nightly build.

2.) Is it possible to move the string to a new resource file?

No, not in 5.0. We thinking about localization wizard in the next version

3.) Is it possible to get a list of all string wich are candidates for "Move to resource file"?
Currently we set it from Warning to Error to find the strings faster^^

If localization is very important for you IMHO it's realy good solution. Also you could get all wagnings for current file by new feature "Inspect Scope".

4.) Thanks for this really helpfull feature =)

"Develop with pleasure!"

0

Also you could get all wagnings for current file by new feature "Inspect Scope".

Can you give me a hint where to find this feature?

0

You could find it in the context menu for a project item in the solution explorer.

0

However I found a problem: Element is localizable is not an issue the inspect scope function can check... there is no option for this in the filter settings (And I'm missing a "reset to default" button ^^)

Sorry for hijacking this thread.

-EDIT-
Ok, when I switch "Element is localizable" from error to warning the inspect scope function does check it and also its listet in the settings.

Is there a reason why this behaviour is?

0

Hello Sven,

In SWA mode Inspect Scope shouldn't show errors - you have live window for
them. But in non-SWA it should. Thanks for heads up, we'll fix it.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


0

Ilya,

the inspection results shows issues in designer.cs files.  Can these be filtered out?

Regards,

Phil Lee

0

2.) Is it possible to move the string to a new resource file?

No, not in 5.0. We thinking about localization wizard in the next version :)


Currently we are localizing our application and I noticed that the missing option to add the string to a new resource file is really bad...

I have to press Shift + Alt + L to locate the File, find project or parent folder to left click and select "Resource File".
Programmers are lazy^^ and a simple solution like in this addon http://www.codeplex.com/ResourceRefactoring would be nice

But instead a "Add new File" in the dropdownlist I would apreciate a button (we have a lot of resources and scrolling to the end.. lazyness you remember^^) wich shows a SaveFileDialog with the folder for the current project or file preselected.

0

The "Inspect Scope" is a realy cool feature, congratulation. What I'm always missing is that I only see the issue. What I also would love to see is the text itsel. Like it is visible for "Find Usage" there you can see the code line.

This helps a lot to identify the issue and I can decide if I have to solve it now or not.

Martyn

0

The resource name is generated by the Class, Method and string name. Since this can contain invalid chars you are replacing them with an underscore.

Here an example:
Text = "exported {0} (duplicates {1})"
Key = "exported__0___duplicates__1__"
I hope you agree that this isn't very nice looking.

I suggest to remove just the invalid characters and set the following character upper case: "Exported0Duplicates1"

Regards
Martyn

0

Hello,

The "Inspect Scope" is a realy cool feature, congratulation. What I'm
always missing is that I only see the issue. What I also would love to
see is the text itsel. Like it is visible for "Find Usage" there you
can see the code line.

This helps a lot to identify the issue and I can decide if I have to
solve it now or not.


Could the "Show Preview" button be of any help?


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

Please sign in to leave a comment.