ReSharper 8.0 Web Help

ReSharper's Code Analysis, enabled by default, constantly inspects and highlights all your code including resource files and resource usages in code files. To resolve the highlighted issues, ReSharper provides a number of resource-specific quick-fixes. There are also some context actions related to resources.

If necessary, you can disable localization inspections for the current project in the action list that appears for localizable strings:
Resources__Quick-Fixes_04
This command command sets the Localizable property in the current project to No.

Tip

To enable localization inspections, change the value of the Localizable property to Yes or Default in the Properties window. To access this window, select the project node in the Solution Explorer, and then choose View | Properties Window on the main menu.

  1. Move to resource
  2. Use resource entry instead of literal
  3. Annotate type with 'Localizable(false)'
  4. Create resource file
  5. Create resource item
  6. Declare resource entry
  7. Override resource entry
  8. Remove resource entry
  9. Remove redundant type
  10. Safe delete resource entry
  11. Move HTML to resource

When a quick-fix or a context action is available, ReSharper displays the corresponding action indicator on the left of your input position in the editor. You can press Alt+Enter or click on the indicator icon to see the list of available quick-fixes and context actions, To apply a desired action, click on it or select it in the list and press Enter.

Move to resource

This quick-fix invokes Move to Resource refactoring to move localizable string to a resource file. It is available when a string is highlighted with a curly underline.

Note

There are two algorithms that can be applied when ReSharper searches for localizable strings: Pessimistic and Optimistic. If the Pessimistic algorithm is chosen, ReSharper analyzes all possible elements, except those which have attribute Localizable(false). If the Optimistic algorithm is chosen, ReSharper analyzes only elements with attribute Localizable(true). Depending on these settings, ReSharper highlights strings and enables this quick-fix.

By default, the Optimistic algorithm is selected. To change the algorithm for the project, click Pessimistic in the Localizable Inspector list in the Properties window. To access this window, select the project node in the Solution Explorer, and then choose View | Properties Window on the main menu.

Resources__Quick-Fixes_05
After applying this quick-fix, follow the steps of the Move to Resource refactoring.

Use resource entry instead of literal

If ReSharper detects that some literal string is defined in resources, it suggests you to replace the string with the resource usage:
Resources__Quick-Fixes_15
After applying this quick-fix, the string is replaced with the resource usage.

Annotate type with localizable(false)

This group of quick-fixes sets false value to the Localizable attribute of the selected type.

Create resource file

If a resource file name is used in a code file, but you haven't created the resource file yet, ReSharper can do it for you. It highlights the resource file name in red and suggests the corresponding quick-fix:
Resources__Quick-Fixes_07
After applying the quick-fix, the missing resource file is created.

Create resource item

If a resource name is used in a code file, but you haven't declared this resource yet, ReSharper can do it for you. It highlights the resource name in red and suggests the corresponding quick-fix:
Resources__Quick-Fixes_08
After applying the quick-fix, the missing resource declaration is added in the resource file.

Declare resource entry

If there are several cultures organised in the culture hierarchy and there is a resource entry that is declared in a culture-specific resource file, but is not declared in the neutral culture, ReSharper highlights the resource declaration with fading and suggests the corresponding quick-fix:
Resources__Quick-Fixes_01
After applying the quick-fix, resource declaration is inserted into the neutral culture where you can replace its value with a new one.

Override resource entry

If there are several cultures organised in the culture hierarchy and there is a resource entry that is declared in the neutral culture, but is not overridden in one or more existing specific culture, ReSharper highlights the name of resource and suggests the corresponding quick-fix:
Resources__Quick-Fixes_09
After applying the quick-fix, resource declaration is inserted into the culture-specific resource file where you can replace its value with a new one.

Remove resource entry

ReSharper suggests this quick-fix in the following cases:

  • A resource entry has equal values in neutral and specific cultures;
  • There are two or more declarations with the same resource name;
  • There are several cultures organised in the culture hierarchy and there is resource entry that is declared in specific culture, but is not declared in neutral culture.
Resources__Quick-Fixes_03
After applying the quick-fix, resource declaration is removed from the current resource file.

Remove redundant type

According to the ReSharper analysis, specifying the string type for resource entry is redundant because it is the default resource entry type. ReSharper highlights attribute and its value with fading and suggests the quick-fix:
Resources__Quick-Fixes_06
After applying the quick-fix, the attribute and its value are removed from resource declaration.

Safe delete

If there are several cultures organised in the culture hierarchy and there is a resource entry that is declared in the neutral culture, but is not overridden in a culture-specific resource file, ReSharper highlights the name of the resource suggests this quick-fix:
Resources__Quick-Fixes_10
After applying this quick-fix, follow the steps of the Safe Delete Resource refactoring.

Move HTML to resource

This context action is available when you select text or a part of HTML code:
Resources__Move_Html_to_Resource_01
After you choose this context action, the Select Resource File drop-down list opens, where you can choose a resource file to move the selected text or HTML code to. Whether resource files exist or not, ReSharper suggests you at least one local and one global resource file. If a resource file does not exist its name is written in italic; it will be created automatically if you choose it.
Resources__Move_Html_to_Resource_02
After you choose a resource file, ReSharper replaces the selected text or HTML code with the resource usage and deploys a Hot Spot Session so that you could finish the definition. The resource key is proposed automatically and highlighted with a red frame; the input focus is set there.
Resources__Move_Html_to_Resource_03
Accept the proposed value or type another resource key and then press Enter or Tab to finish the operation.