ReSharper 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 special number of Quick-Fixes related to resources:

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

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

Move to resource

This quick-fix moves localizable string to a resource file. It is available when a string is highlighted with a curly underline.

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 this settings, ReSharper highlights strings and enables the Move to resource refactoring.

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 the Properties window, select a project node in Solution Explorer, and then, on the View menu, click Properties Window.


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:

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.

Disable localization for this project

If you want to disable the Localizable property in the current project, apply this quick-fix:

After applying the quick-fix, analysis is disabled.

 Tip

To enable localizable features, change the value of the Localizable property from No to Yes or Default in the Properties window. To access the Properties window, select a project node in Solution Explorer, and then, on the View menu, click Properties Window.

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:

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:

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:

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 specific culture, ReSharper highlights the name of resource and suggests the corresponding quick-fix:

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.

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 in grey and suggests the quick-fix:

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:

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:

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.

After you choose a resource file, ReSharper replaces the selected text or HTML code with the resource usage. The resource key, proposed automatically, is highlighted with a red frame and the input focus is set there.

Type a resource key and press Enter or Tab to finish the operation.

See Also

Procedures