DevCase VB.NET Code Analysis
Roslyn analyzers and code fixes for Visual Basic .NET, packaged as a Visual Studio extension.
Full rule specifications and code examples are available in the official repository: ElektroStudios / DevCase-VB.NET-Code-Analysis
👋 Introduction
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 in our official repository 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.
💡 Motivation
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.
⚡ The Real Question
Why keep fixing the same mistakes by hand when the compiler platform can point at them, and fix them, as you type?
🤖 Features
- 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 NETCOREAPP blocks with the recommended modern APIs, keeping the original code untouched in the #Else branch.
- Behavior first: when a fix offers several actions, the first one keeps the current behavior and only makes it explicit (for example
DateTimeKind.Unspecified or CultureInfo.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.
📋 Rules
For full documentation, edge cases, and VB.NET code examples for each rule, please visit the Docs/Rules folder in the official GitHub repository.
| ID |
Rule |
Severity |
Category |
Code fix |
DCA001 |
⏳ Missing ConfigureAwait(False) |
Error |
Reliability |
✔️ |
DCA002 |
🧱 Blocking .Result on a task |
Error |
Reliability |
✔️ |
DCA003 |
🤫 Silent guard clause |
Error |
Reliability |
✔️ |
DCA004 |
📜 Missing Option statements |
Warning |
Style |
✔️ |
DCA005 |
🏗️ Missing explicit constructor |
Warning |
Design |
✔️ |
DCA006 |
📦 Type in the global namespace |
Warning |
Design |
✔️ |
DCA007 |
📝 Public member without XML documentation |
Warning |
Documentation |
✔️ |
DCA008 |
🧾 <param> tags do not match the parameters |
Warning |
Documentation |
✔️ |
DCA009 |
🔤 String comparison argument omitted |
Warning |
Globalization |
✔️ (×2) |
DCA010 |
🚩 <Flags> enum member without bit-shift syntax (disabled by default) |
Warning |
Style |
✔️ |
DCA011 |
🔁 Argument guards with a modern throw-helper equivalent (.NET Framework) |
Info |
Portability |
✔️ |
DCA012 |
💥 Thrown exception is not documented |
Warning |
Documentation |
✔️ |
DCA013 |
🚀 .NET Framework API with a modern .NET equivalent (.NET Framework) |
Info |
Portability |
✔️ |
DCA014 |
🗂️ File-system loop without Thread.CurrentThread.Join(0) |
Warning |
Reliability |
✔️ |
DCA015 |
🔄 Method calls itself (recursion) |
Warning |
Design |
❌ |
DCA016 |
⚡ Async Sub that is not an event handler |
Warning |
Reliability |
✔️ |
DCA017 |
⏱️ Regular expression without match timeout |
Error |
Security |
✔️ |
DCA018 |
🕒 DateTime created without DateTimeKind |
Warning |
Reliability |
✔️ |
DCA019 |
🌍 Date or time parsed without a format provider |
Warning |
Globalization |
✔️ |
DCA020 |
🚩 <Flags> enumeration without a None zero value |
Warning |
Design |
✔️ |
DCA021 |
🔍 LINQ method instead of Find / Exists / TrueForAll |
Warning |
Performance |
✔️ |
DCA022 |
🎯 LINQ method instead of the indexer |
Warning |
Performance |
✔️ |
DCA023 |
🔄 Negated comparison |
Warning |
Style |
✔️ |
DCA024 |
🔁 Catch block that only rethrows |
Warning |
Design |
✔️ |
DCA025 |
🧹 Redundant null check before TypeOf |
Warning |
Style |
✔️ |
DCA026 |
🔤 Text encoding not specified |
Warning |
Globalization |
✔️ |
DCA027 |
💤 Thread.Sleep in an Async method |
Warning |
Reliability |
✔️ |
DCA028 |
🧵 Windows Forms entry point without <STAThread> |
Warning |
Reliability |
✔️ |
DCA029 |
➕ String concatenated with + |
Warning |
Style |
✔️ |
DCA030 |
📦 Array creation expression can be an array literal |
Info |
Style |
✔️ |
DCA031 |
🏷️ Array designator on the variable name |
Info |
Style |
✔️ |
DCA032 |
🛑 End statement |
Warning |
Reliability |
❌ |
DCA033 |
🚧 On Error statement |
Warning |
Reliability |
❌ |
DCA034 |
↪️ GoTo statement |
Info |
Design |
❌ |
DCA035 |
🌀 Application.DoEvents inside a loop |
Warning |
Reliability |
❌ |
DCA036 |
🔐 SyncLock on a publicly accessible or weak-identity object |
Warning |
Reliability |
❌ |
DCA037 |
🔓 Monitor.Enter without Monitor.Exit in a Finally block |
Warning |
Reliability |
❌ |
DCA038 |
⏸️ Thread.Suspend or Thread.Resume |
Warning |
Reliability |
❌ |
DCA039 |
📮 Delegate BeginInvoke without EndInvoke |
Warning |
Reliability |
❌ |
DCA040 |
👯 Duplicated condition in If/ElseIf or Select Case |
Warning |
Reliability |
❌ |
DCA041 |
🪞 All branches of a conditional structure are identical |
Warning |
Reliability |
❌ |
DCA042 |
🧬 Two branches of a conditional structure are identical |
Info |
Design |
❌ |
DCA043 |
🟰 Identical expressions on both sides of a binary operator |
Warning |
Reliability |
❌ |
DCA044 |
⏲️ DateTime.Now used to measure elapsed time |
Info |
Reliability |
❌ |
DCA045 |
🗃️ Path.GetTempFileName creates a predictable temporary file |
Warning |
Security |
✔️ |
DCA046 |
🧨 Exception thrown in a Finally block |
Warning |
Reliability |
❌ |
DCA047 |
☠️ Exception thrown in Finalize |
Warning |
Reliability |
❌ |
DCA048 |
🫳 Exception thrown in a property getter |
Info |
Design |
❌ |
📝 Requirements
- 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.
🚀 Getting Started
Download the extension directly from this Marketplace page, or search for DevCase VB.NET Code Analysis inside the Visual Studio Manage Extensions dialog.
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) appear in the Messages tab of the Error List and as gray dots under the code.
⚙️ Configuration
All the options can be easily configured in your .editorconfig 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 = none