JetBrains Rider 2024.1 Help

Code style assistance in Visual Basic

The main JetBrains Rider's code style assistance features available in C# (for example Naming style, Apply formatting rules, Code cleanup) are also supported in Visual Basic. You can find the detailed information on these features in the corresponding topics of the Code style and cleanup section.

Formatting style

An important aspect of code style is how to format the code, that is, how to use whitespaces, tabs, and line breaks to arrange code elements, whether and how to use tabs for indents, whether and how to wrap long lines, and so on.

The extensive set of JetBrains Rider code formatting rules has a default configuration that takes into account numerous best practices. You can configure every detail of formatting rules and enforce the rules in your code. These rules are applied when JetBrains Rider produces new code with code completion and code generation features, applies code templates and performs refactorings. The formatting rules can also be applied to the existing code in the current selection, current file, or in a larger scope up to the entire solution.

Here is an example of a code block reformatted with JetBrains Rider.

Before:

JetBrains Rider: Code cleanup in Visual Basic

After:

JetBrains Rider: Code cleanup in Visual Basic

For more information, see Apply formatting rules.

Naming style

JetBrains Rider helps you define, control, and apply desired naming styles for symbols in your code. There is a set of rules, each of which targets specific identifiers with the set of constraints . Each rule can have one or more associated styles that define capitalization of compound words, underscores, suffixes, prefixes, and so on.

These rules are taken into account when JetBrains Rider produces new code with code completion and code generation features, applies code templates and performs refactorings. JetBrains Rider also helps you detect and fix violations of naming rules. If necessary, the automatic checkup of naming rules can be configured or disabled.

Edit naming rule

  1. In Rider settings Ctrl+Alt+S, go to Editor | Code Style | VB.NET and open the Naming tab.

  2. Select the desired rule in the list.

  3. In the right part of the page, check the existing style for the rule.

  4. If the existing style is acceptable, but you would like to allow other styles for this rule, click Add When there are several styles for a single rule, JetBrains Rider does not report code style violation if a corresponding symbol name matches at least one of these styles. Otherwise, JetBrains Rider detects a code style violation and suggests renaming the symbol according to the default style (the first style in the list). To change the default style, use Move Up and Move Down buttons.

  5. To configure a specific style, select it in the list and configure prefix, suffix, and choose a naming style.

  6. To remove an unnecessary style, select it in the list and click Remove.

  7. If necessary, you can disable reporting code style violations associated with this rule, while still allowing JetBrains Rider to detect other naming rule violations. To do so, clear the Enable inspections checkbox.

  8. Click Save in the Settings dialog to apply the modifications and let JetBrains Rider choose where to save them, or save the modifications to a specific settings layer by choosing this layer from the Save selector. For more information, see layer-based settings.

Last modified: 26 May 2024