JetBrains Rider 2018.1 Help

Coding Assistance in Visual Basic .NET

All JetBrains Rider's coding assistance features available in C# are also supported in Visual Basic .NET. You can find the detailed information on these features in the corresponding topics of the Coding Assistance section.

In this topic, you can find some examples of using coding assistance features in Visual Basic .NET:

Syntax highlighting

You can establish a custom font and color scheme, for more information, see Configuring Colors and Fonts.

Default syntax highlighting:

Coding Assistance Syntax Highlighting VB NET

Code completion

Code Completion features help you write code faster by providing a set of items to complete based on surrounding context. For more information, see Code Completion (IntelliSense).

Three Code Completion features are available in Visual Basic:

  • Basic Completion

    JetBrains Rider suggests namespaces, types, methods, fields, properties, etc.

    ReSharper by Language Visual Basic Symbol Completion
    Enum members are also included into basic completion list.
    ReSharper by Language Visual Basic Symbol Completion enum
    If you use anonymous types, JetBrains Rider takes their properties into account and displays them in completion list along with other available items.
    ReSharper by Language Visual Basic Symbol Completion anonymous type

  • Smart Completion

    JetBrains Rider filters items in code completion list according to the type expected in current context. Look at the example below, only those items that have string type are displayed in the drop-down list.

    ReSharper by Language Visual Basic Smart Completion

  • Import Symbol Completion

    JetBrains Rider provides completion items for types and extension methods that are not visible through import directives in current context.

    ReSharper by Language Visual Basic Import Symbol Completion

Examples of Context Actions

JetBrains Rider provides a set of context actions that target Visual Basic .NET code. You can find the full list of these actions in the Editor | Context actions | Visual Basic .NET page of JetBrains Rider Settings. If necessary, you can also disable some of the actions using this page.

As soon as a context action becomes available for the current caret position, JetBrains Rider displays the corresponding action indicator ThemedIcon ContextAction Screen Gray to the left of the caret. Sometimes however, JetBrains Rider provides several contextually available features for the current caret position. In this case, the action indicator corresponding to the action with the highest priority is shown, and all other actions only appear when you expand the action list by clicking on the action indicator or pressing Alt+Enter Context actions have the lowest priority, therefore, they often appear at the bottom of the action list:

Here are some examples of context actions for Visual Basic .NET:

Add new format item
If you need to add some dynamic data to a string literal, use this context action.

ReSharper by Language Visual Basic Quick Fixes add new format item 01
It wraps the string literal with the String.Format method call, adds a placeholder at the current caret position and lets you specify the corresponding parameter.

Change member visibility
If you need to adjust member visibility, JetBrains Rider provides a context action that allows doing this quickly.

ReSharper by Language Visual Basic Context Actions change visibility 01
ReSharper by Language Visual Basic Context Actions change visibility 02

Convert Function to Sub
In case you want to convert a Visual Basic .NET Function to a Sub, there's the corresponding context action as well.

ReSharper by Language Visual Basic Context Actions convert function to sub 01

Convert to property with backing field
You can easily transform an automatic property to a property with backing field. Place the caret at the name of an automatic property and press Alt+Enter. JetBrains Rider suggests the appropriate context action.

ReSharper by Language Visual Basic Context Actions automatic property 01

Create overload without parameter
For each parameter of a function there's a context action that will create a function without that parameter which calls the original function.

ReSharper by Language Visual Basic Context Actions create overload 01
ReSharper by Language Visual Basic Context Actions create overload 02

Implement member
After you add a new member to a base class, the next logical step is to implement this member in all classes derived from the base class. You can write code manually, but a better decision is to apply the appropriate context action.

ReSharper by Language Visual Basic Context Actions implement member 01
JetBrains Rider automatically detects all derived classes and prompts you to decide where a base class member should be implemented and generates code.
ReSharper by Language Visual Basic Context Actions implement member 02

Rearrange code

Rearranging Code Elements is available in Visual Basic as well. For example, you can move a member declaration up or down within a type.

ReSharper by Language Visual Basic Moving Code Elements 01
You can move a statement out of or into a block of code. For example, to move If statement out of For Each loop, press Ctrl+Shift+Alt+Left.
ReSharper by Language Visual Basic Moving Code Elements 02
You can reorder parameters of a method call or a method declaration. For example, to move FileId argument to the right, press Ctrl+Shift+Alt+Right.
ReSharper by Language Visual Basic Moving Code Elements 03

Last modified: 20 August 2018

See Also