Create a Context Action

Last modified: 04 July 2023

What you should know beforehand:

Examples (?):

The purpose of context actions is to quickly introduce a minor change to the code, like changing access modifiers, convert foreach to for, and so on. When a context action is available for the current caret position, ReSharper displays the "hummer" hummer action indicator. The list of possible context actions is displayed after a user presses Alt+Enter.

context-action

For example, let's create a very simple context action that will be applicable to variable declarations. If a variable name contains any character in uppercase, the context action will suggest to convert the name to lowercase (of course, from the point of functionality, such action is absolutely useless).