ReSharper 2020.2 Help

Use Base Type Where Possible refactoring

ReSharper | Refactor | Use Base Type where Possible…
ReSharper_UseBaseTypeAction

This refactoring helps replace references to a type with references to one of its base types. ReSharper will analyze all references to the type in the whole solution and update those that can be safely replaced with references to the selected base type. Optionally, you can also replace references in is and typeof operators.

Replace references to a type with references to one of its base types

  1. Select a type in one of the following ways:

    • In the editor, set the caret at the name of a type.

    • Select a type in the Solution Explorer.

    • Select a type in the File Structure window.

    • Select a type in the Class View.

    • Select a type in the Object Browser.

    • Select a type in the type dependency diagram.

  2. Do one of the following:

    • Press Control+Shift+R and then choose Use Base Type where Possible

    • Right-click and choose Refactor | Use Base Type where Possible in the context menu.

    • Choose ReSharper | Refactor | Use Base Type where Possible… in the main menu.

    The Use Base Type where Possible dialog will open.

  3. Select one of base types.

  4. Optionally, select whether you want to replace type usages in the is operator and/or in the typeof operator.

  5. To apply the refactoring, click Next.

  6. If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.

ReSharper: Use Base Type Where Possible refactoring

This feature is supported in the following languages and technologies:

Language: C#Language: VB.NETLanguage: C++Language: HTMLLanguage: ASP.NETLanguage: RazorLanguage: JavaScriptLanguage: TypeScriptLanguage: CSSLanguage: XMLLanguage: XAMLLanguage: ResxLanguage: Build ScriptsLanguage: ProtobufLanguage: JSON
Feature is available in C#Feature is available in Visual Basic .NETFeature is not available in C++Feature is not available in HTMLFeature is available in ASP.NETFeature is not available in RazorFeature is not available in JavaScriptFeature is not available in TypeScriptFeature is not available in CSSFeature is not available in XMLFeature is available in XAMLFeature is not available in Resource filesFeature is not available in build script filesFeature is not available in ProtobufFeature is not available in JSON

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by Language section.

Last modified: 03 September 2020