Visual Studio Marketplace: Download Extension
DevCase VB.NET Code Analysis is a set of Roslyn diagnostic rules for Visual Basic .NET, most of them with an automatic code fix (Visual Studio lightbulb action). It finds and repairs problems that the built-in .NET analyzers do not cover for VB.NET: deadlock-prone Await expressions, silent guard clauses, missing or incomplete XML documentation, recursion, file-system loops that freeze the message pump, regular expressions without a ReDoS timeout, ambiguous dates, and much more.
Several rules are VB.NET equivalents of SonarQube rules, with an automatic fix that respects the semantics of the original code. Each rule document lists any overlap with Microsoft's built-in analyzers.
The whole project, analyzers, code fixes and tests included, is written in VB.NET with Option Strict On, Option Explicit On and Option Infer Off.
Over the years, I have established a rigorous custom coding standard for my VB.NET libraries: fail-fast argument validation, ConfigureAwait(False) on virtually every Await, comprehensive XML documentation covering absolutely every public and private member, mandating iterative methods over recursion, bit-shifted <Flags> enums to prevent manual integer calculation mistakes, explicit Option directives, etc. To enforce this discipline, I developed offline VisualBasicSyntaxRewriter snippets that I run across my codebases.
Although functional, that offline methodology is a tedious and time-consuming chore relegated to post-coding manual reviews, lacking any semantic context. DevCase VB.NET Code Analysis turns that standard into live diagnostics that show up while typing, with one-click fixes, and with semantic precision instead of text heuristics.
Why keep fixing the same mistakes by hand when the compiler platform can point at them, and fix them, as you type?
- A comprehensive set of diagnostic rules, most of them featuring a code fix, all fixes supporting Fix All (document, project and solution). Rules without a safe, behavior-preserving fix only report.
- Semantic precision: rules bind symbols through the Roslyn semantic model, so look-alike names (
myAsyncSettings.Result) are not reported and no fix produces code that does not compile. - .NET Framework migration helpers: dedicated rules prepare .NET Framework code for modern .NET by adding
#If NETCOREAPPblocks with the recommended modern APIs, keeping the original code untouched in the#Elsebranch. - Behavior first: when a fix offers several actions, the first one keeps the current behavior and only makes it explicit (for example
DateTimeKind.UnspecifiedorCultureInfo.CurrentCulture); fixes that could change the result are never applied silently. - Respectful fixes: preserve comments, trivia, region layout, line endings (CRLF/LF) and indentation; never reformat unrelated code.
- Configurable through
.editorconfig(custom options and standard severity overrides). - Visual Studio 2022 and 2026 (amd64 and arm64) from a single VSIX.
Click a rule to see its purpose, detection details, edge cases and VB.NET code examples.
- Visual Studio 2026 (18.x) or Visual Studio 2022 (17.8 or later), on Windows.
- The rules analyze Visual Basic projects that target any framework: .NET Framework, .NET Standard or modern .NET.
- Navigate to the Releases page.
- Download
DevCase.CodeAnalysis.Vsix.vsix. - Close Visual Studio and double-click the
.vsixfile to install it.
-
Open
DevCase.CodeAnalysis.slnin Visual Studio (workload: Visual Studio extension development). -
Select the
Releaseconfiguration and buildDevCase.CodeAnalysis.Vsix, or run this command from the Developer PowerShell for VS:msbuild src\DevCase.CodeAnalysis.Vsix\DevCase.CodeAnalysis.Vsix.vbproj /restore /p:Configuration=Release
-
The package is generated at
src\DevCase.CodeAnalysis.Vsix\bin\Release\net472\DevCase.CodeAnalysis.Vsix.vsix.
To debug the analyzers, set DevCase.CodeAnalysis.Vsix as the startup project and press F5: an experimental instance of Visual Studio starts with the extension loaded.
Note
Analyzers installed through a VSIX run inside the IDE (live analysis, Error List and lightbulb), not on command-line builds. Info-level rules (DCA011, DCA013, DCA030, DCA031, DCA034, DCA042, DCA044, DCA048, DCA049, DCA050, DCA052, DCA053) appear in the Messages tab of the Error List and as gray dots under the code.
All the options are set in an .editorconfig file (or a global analyzer configuration file):
[*.vb]
# DCA010 (disabled by default because of legacy P/Invoke flag enums).
devcase_analyzers.dca010_enabled = true
# DCA001 code fix: emit ConfigureAwait(continueOnCapturedContext:=False).
devcase_analyzers.configure_await_named_argument = true
# DCA006 code fix: namespace used to wrap types declared in the global namespace.
# When not set: the namespace already declared in the file, or else the assembly name.
devcase_analyzers.default_namespace = Contoso.Tools
# DCA011 code fix: conditional compilation symbol of the throw-helper branch.
devcase_analyzers.dca011_condition = NET8_0_OR_GREATER
# DCA017 code fix: match timeout in milliseconds (default: 30000).
devcase_analyzers.dca017_timeout_ms = 30000
# Standard Roslyn severity overrides.
dotnet_diagnostic.DCA007.severity = suggestion
dotnet_diagnostic.DCA015.severity = noneEvery rule document has a How to disable section with ready-to-copy examples. In short:
# .editorconfig: one rule, or a whole category, for a solution, project or folder.
[*.vb]
dotnet_diagnostic.DCA022.severity = none
dotnet_analyzer_diagnostic.category-Performance.severity = suggestion' A few lines of code.
#Disable Warning DCA024 ' Reason.
' ...
#Enable Warning DCA024' A type or member (category and "ID:Title" as shown in each rule document).
<System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "DCA024:Catch block only rethrows the exception", Justification:="Reason.")>The test project (xUnit v3) builds in-memory VB.NET projects and:
- checks the exact spans of every expected diagnostic;
- applies every code fix repeatedly, re-parsing the text between passes like the IDE does, and verifies that the fixed code still compiles;
- verifies Fix All batch merging;
- runs every analyzer, code fix and Fix All test twice, with LF and CRLF line endings, and checks that the fixes never mix line endings (the Roslyn formatter writes the line ending of the operating system);
- compiles the .NET Framework rules against the real .NET Framework 4.8 reference assemblies, and the modern branch of their fixes against .NET;
- enforces every DCA rule on its own code at build time: the CodeFixes and Tests projects reference the analyzers as analyzers, the Analyzers project is checked by a self-analysis test, and Visual Studio's code style suggestions are raised to warnings in the repository
.editorconfig, so the solution builds with 0 warnings; - verifies that every suppression mechanism documented in the rules (
.editorconfig,#Disable Warning,SuppressMessage) works; - runs all the analyzers on their own source code (dogfooding) and checks that the code base contains no recursion.
dotnet test tests/DevCase.CodeAnalysis.Testssrc/DevCase.CodeAnalysis.Analyzers netstandard2.0 Diagnostic analyzers and shared detection logic
src/DevCase.CodeAnalysis.CodeFixes netstandard2.0 Code fix providers
src/DevCase.CodeAnalysis.Vsix net472 VSIX container (VS 2022 + VS 2026, amd64 + arm64)
tests/DevCase.CodeAnalysis.Tests net10.0 xUnit v3 tests
Explore the complete list of changes, bug fixes, and improvements across different releases by clicking here.
Your contribution is highly appreciated!. If you have any ideas, suggestions, or encounter issues, feel free to open an issue by clicking here.
Your input helps make this Work better for everyone. Thank you for your support! ๐
This work is distributed for educational purposes and without any profit motive. However, if you find value in my efforts and wish to support and motivate my ongoing work, you may consider contributing financially through the following options:
| Platform | How to Support |
|---|---|
| Become my sponsor on GitHub Contribute any amount you prefer and unlock rewards! |
|
| Support me on Ko-fi Buy me a coffee! |
|
| Become a Patron on Patreon Support my open-source work regularly! |
|
| Make a PayPal Donation Donate any amount you like via PayPal! |
|
| Purchase my software at Envato's CodeCanyon Discover my desktop tools and DevCase Class Library for .NET, an extensive API suite. |
This work relies on the following technologies, libraries or resources:
This software and its associated repository are provided strictly on an "as is" basis, without warranties of any kind, whether express or implied. This includes, but is not limited to, any implied warranties of merchantability, reliability, or fitness for a particular purpose.
The authors and copyright holders assume no liability for any direct, indirect, incidental, or consequential damagesโincluding data loss or system errorsโarising from the use, misuse, or inability to use this software. You are solely responsible for determining the appropriateness of using this tool and assume all associated risks.
Code fixes modify source code: review the changes they make and keep your code under version control.
Furthermore, this project operates entirely independently. The utilization of any third-party libraries or components within this software does not imply any affiliation with, or endorsement or approval by, their respective original authors.
By using this software, you agree to indemnify and hold harmless the authors from any claims, damages, or liabilities arising from your use or misuse of it.
This project is licensed under the Apache License, Version 2.0. See the License file for details.