Grammar and spelling analysis
One important task of code inspection is the analysis of grammar and spelling in natural languages. ReSharper will look for spelling and grammar errors in identifiers, comments, and string literals. When it detects a potential error or a typo, it will let you know in the same way as for other code issues — in design time or when you run code inspection in specific scope.
In this section:
By default, ReSharper checks spelling and grammar using the 'English (USA)' dictionary, but you can install dictionaries for other languages.
Select ReSharper | Options from the main menu or press Alt+R O, then choose Tools | Grammar and Spelling | General on the left.
Click Add.
In the dialog that opens, select one or more languages and click Install.
The selected dictionaries will be downloaded and installed.
Click Save in the Options dialog to apply the modifications and let ReSharper choose where to save them, or save the modifications to a specific settings layer by choosing this layer from the Save To selector. For more information, see manage and share resharper settings.
note
In addition to general-purpose dictionaries, you can add custom spellchecker dictionaries to extend the list of acceptable words.
By default, spelling and grammar inspections are enabled for almost all contexts. You can enable/disable individual inspections and change their severity levels by searching for typo
and grammar
on the Code Inspection | Inspection Severity page of ReSharper options Alt+R, O.
If you have methods that are supposed to receive raw text with spelling and grammar errors, you can mark the corresponding parameters with the [IgnoreSpellingAndGrammarErrors] from JetBrains.Annotations. This will disable warnings for callers of the method.
public class Sample
{
void Out([IgnoreSpellingAndGrammarErrors] string str)
{
Console.WriteLine(str);
}
void Test()
{
// no warnings
Out("wiht erorrs speld texxt");
}
}
You can disable grammar and spelling analysis by clearing the Grammar and Spelling checkbox on the Environment | Products & Features page of ReSharper options Alt+R, O.
This feature is supported in the following languages and technologies:
The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the Languages and frameworks section.