ReSharper 2017.1 Help

Code Inspection and Quick-Fixes in Visual Basic .NET

Almost all ReSharper's code analysis features available in C# (except for Value Tracking) are also supported in VB.NET. You can find the detailed information on these features in the corresponding topics of the Code Analysis section.

In this topic, you can find some examples of using code analysis features in VB.NET:

Code Inspection

ReSharper's static code analysis can detect more than 150 different errors and problems in VB.NET code.

The analysis is performed by applying code inspections to the current document or in any specified scope.

/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Code_Highlighting__Error.png

To look through the list of available inspections for VB.NET, open the Code Inspection | Inspection Severity page of ReSharper options, and then expand the VB.NET node.

Solution-Wide Analysis

ReSharper does not only analyze errors in the current file, but also inspects the whole solution taking the dependencies between files into account and shows the results of analysis in the Errors in Solution window. For more information, see Solution-Wide Analysis.

/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Errors_in_Solution.png

Inspect This

Inspect This is a shortcut to several analysis features. Those are rather powerful and allow you to see how values and method calls flow through you code. The list of available features depends on the current context.

/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Inspect_This.png
For more information, see Call Tracking, Value Tracking and Exploring Type Hierarchy.

Examples of Quick-fixes

Remove redundant 'imports'
If none of the symbols from a particular namespace are used, the corresponding Imports directive is considered as redundant.

/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Quick-Fixes__remove_redundant_import_01.png
ReSharper provides the quick-fix to remove all such directives from a file.
/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Quick-Fixes__remove_redundant_import_02.png

Import type
If you use a symbol from a namespace that is not imported, ReSharper suggests to import the corresponding namespace and provides the necessary quick-fix.

/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Quick-Fixes__import_type_01.png

Add 'Async' modifier
Asynchronous operations have some advantages over synchronous programming, so ReSharper keeps pace with times and new language features for asynchronous programming are thoroughly supported.

/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Quick-Fixes__make_async_01.png
The GetQuotesAsync function contains the await operator, but the function isn't defined as asynchronous. ReSharper detects such mismatch and prompts to improve the code using the Add 'Async' modifier quick-fix. After applying the quick-fix, the missing modifier is added to the function declaration.

Change type
If the type of the method argument doesn't match the type of the corresponding method parameter, ReSharper suggests to change the type of argument and provides the necessary quick-fix.

/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Quick-Fixes__change_type_01.png

Initialize auto-property from constructor parameter
If you have a constructor parameter and you want to initialize an existing auto-property with parameter's value, use this quick-fix.

/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Quick-Fixes__initialize_auto-property_01.png
/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Quick-Fixes__initialize_auto-property_02.png

Create method from usage
If there is a call of a method that does not exist yet, ReSharper provides the necessary quick-fix to create such method.

/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Quick-Fixes__create_method_01.png
/help/img/dotnet/2017.1/ReSharper_by_Language__Visual_Basic__Quick-Fixes__create_method_02.png

Last modified: 12 October 2017

See Also