Skip to content

Commit 28f1693

Browse files
Light Freshness Edit: ASP.NET - Diagnostics + Hosts (#37024)
* edits to refresh content * edits to refresh content * edits * refresh content, update <xref> links * edits * edit link * rm link * refresh content, edits * edits * Apply suggestions from code review Co-authored-by: Wade Pickett <wpickett@microsoft.com> --------- Co-authored-by: Wade Pickett <wpickett@microsoft.com>
1 parent 02a4da0 commit 28f1693

3 files changed

Lines changed: 632 additions & 2823 deletions

File tree

Lines changed: 68 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,74 @@
11
---
2-
title: Code analysis in ASP.NET Core apps
2+
title: Diagnostic Code Analysis in ASP.NET Core Apps
33
author: tdykstra
4-
description: Learn about source code analysis in ASP.NET Core
4+
description: Review the list of diagnostic codes for ASP.NET Core and get details for specific diagnostic identifiers (IDs), such as ASP0007, BL0001, and MVC1006.
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: tdykstra
7-
ms.date: 07/08/2024
7+
ms.date: 04/22/2026
88
uid: diagnostics/code-analysis
9+
10+
# customer intent: As an ASP.NET developer, I want to get details for specific diagnostic codes in ASP.NET Core, so I can understand the diagnostic messages in my apps.
911
---
10-
# Code analysis in ASP.NET Core apps
11-
12-
.NET compiler platform analyzers inspect application code for code quality and style issues. This document lists diagnostics for ASP.NET Core. For information on .NET diagnostics, see [Overview of .NET source code analysis](/dotnet/fundamentals/code-analysis/overview).
13-
14-
The following list contains the diagnostics for ASP.NET Core. Not all of the diagnostics shown are available in older versions of ASP.NET Core.
15-
16-
Diagnostic ID:
17-
18-
* [ASP0000](xref:diagnostics/asp0000)
19-
* [ASP0001](xref:diagnostics/asp0001)
20-
* [ASP0003](xref:diagnostics/asp0003)
21-
* [ASP0004](xref:diagnostics/asp0004)
22-
* [ASP0005](xref:diagnostics/asp0005)
23-
* [ASP0006](xref:diagnostics/asp0006)
24-
* [ASP0007](xref:diagnostics/asp0007)
25-
* [ASP0008](xref:diagnostics/asp0008)
26-
* [ASP0009](xref:diagnostics/asp0009)
27-
* [ASP0010](xref:diagnostics/asp0010)
28-
* [ASP0011](xref:diagnostics/asp0011)
29-
* [ASP0012](xref:diagnostics/asp0012)
30-
* [ASP0013](xref:diagnostics/asp0013)
31-
* [ASP0014](xref:diagnostics/asp0014)
32-
* [ASP0015](xref:diagnostics/asp0015)
33-
* [ASP0016](xref:diagnostics/asp0016)
34-
* [ASP0017](xref:diagnostics/asp0017)
35-
* [ASP0018](xref:diagnostics/asp0018)
36-
* [ASP0019](xref:diagnostics/asp0019)
37-
* [ASP0020](xref:diagnostics/asp0020)
38-
* [ASP0021](xref:diagnostics/asp0021)
39-
* [ASP0022](xref:diagnostics/asp0022)
40-
* [ASP0023](xref:diagnostics/asp0023)
41-
* [ASP0024](xref:diagnostics/asp0024)
42-
* [ASP0025](xref:diagnostics/asp0025)
43-
* [ASP0026](xref:diagnostics/asp0026)
44-
* [ASP0027](xref:diagnostics/asp0027)
45-
* [ASP0028](xref:diagnostics/asp0028)
46-
* [BL0001](xref:diagnostics/bl0001)
47-
* [BL0002](xref:diagnostics/bl0002)
48-
* [BL0003](xref:diagnostics/bl0003)
49-
* [BL0004](xref:diagnostics/bl0004)
50-
* [BL0005](xref:diagnostics/bl0005)
51-
* [BL0006](xref:diagnostics/bl0006)
52-
* [BL0007](xref:diagnostics/bl0007)
53-
* [BL0008](xref:diagnostics/bl0008)
54-
* [MVC1000](xref:diagnostics/mvc1000)
55-
* [MVC1001](xref:diagnostics/mvc1001)
56-
* [MVC1002](xref:diagnostics/mvc1002)
57-
* [MVC1003](xref:diagnostics/mvc1003)
58-
* [MVC1004](xref:diagnostics/mvc1004)
59-
* [MVC1005](xref:diagnostics/mvc1005)
60-
* [MVC1006](xref:diagnostics/mvc1006)
12+
13+
# Diagnostic code analysis in ASP.NET Core apps
14+
15+
.NET compiler platform analyzers inspect application code for code quality and style issues.
16+
17+
This article provides links to specific diagnostic messages for ASP.NET Core. For more information on .NET diagnostics, see [Overview of .NET source code analysis](/dotnet/fundamentals/code-analysis/overview).
18+
19+
## Diagnostic codes
20+
21+
The following table lists the diagnostics available for ASP.NET Core applications.
22+
23+
> [!NOTE]
24+
> Not all diagnostics are available in older versions of ASP.NET Core.
25+
26+
| Diagnostic ID | Message |
27+
| --- | --- |
28+
| **[ASP0000](xref:diagnostics/asp0000)** | Don't call `IServiceCollection.BuildServiceProvider` in `ConfigureServices` |
29+
| **[ASP0001](xref:diagnostics/asp0001)** | Authorization middleware is incorrectly configured |
30+
| **[ASP0003](xref:diagnostics/asp0003)** | Don't use model binding attributes with route handlers |
31+
| **[ASP0004](xref:diagnostics/asp0004)** | Don't use action results with route handlers |
32+
| **[ASP0005](xref:diagnostics/asp0005)** | Don't place attribute on method called by route handler lambda |
33+
| **[ASP0006](xref:diagnostics/asp0006)** | Don't use nonliteral sequence numbers |
34+
| **[ASP0007](xref:diagnostics/asp0007)** | Route parameter and argument optionality is mismatched |
35+
| **[ASP0008](xref:diagnostics/asp0008)** | Don't use `ConfigureWebHost` with `WebApplicationBuilder.Host` |
36+
| **[ASP0009](xref:diagnostics/asp0009)** | Don't use `Configure` with `WebApplicationBuilder.WebHost` |
37+
| **[ASP0010](xref:diagnostics/asp0010)** | Don't use `UseStartup` with `WebApplicationBuilder.WebHost` |
38+
| **[ASP0011](xref:diagnostics/asp0011)** | Suggest using `builder.Logging` over `Host.ConfigureLogging` or `WebHost.ConfigureLogging` |
39+
| **[ASP0012](xref:diagnostics/asp0012)** | Suggest using `builder.Services` over `Host.ConfigureServices` or `WebHost.ConfigureServices` |
40+
| **[ASP0013](xref:diagnostics/asp0013)** | Suggest switching from using `Configure` methods to `WebApplicationBuilder.Configuration` |
41+
| **[ASP0014](xref:diagnostics/asp0014)** | Suggest using top level route registrations |
42+
| **[ASP0015](xref:diagnostics/asp0015)** | Suggest using `IHeaderDictionary` properties |
43+
| **[ASP0016](xref:diagnostics/asp0016)** | Don't return a value from `RequestDelegate` |
44+
| **[ASP0017](xref:diagnostics/asp0017)** | Invalid route pattern |
45+
| **[ASP0018](xref:diagnostics/asp0018)** | Unused route parameter |
46+
| **[ASP0019](xref:diagnostics/asp0019)** | Suggest using `IHeaderDictionary.Append` or the indexer |
47+
| **[ASP0020](xref:diagnostics/asp0020)** | Complex types referenced by route parameters must be parsable |
48+
| **[ASP0021](xref:diagnostics/asp0021)** | Return type of the `BindAsync` method must be `ValueTask<T>` |
49+
| **[ASP0022](xref:diagnostics/asp0022)** | Route conflict detected between route handlers ([Minimal API apps](/aspnet/core/fundamentals/apis)) |
50+
| **[ASP0023](xref:diagnostics/asp0023)** | Route conflict detected between route handlers |
51+
| **[ASP0024](xref:diagnostics/asp0024)** | Route handler has multiple parameters with the `[FromBody]` attribute |
52+
| **[ASP0025](xref:diagnostics/asp0025)** | Use `AddAuthorizationBuilder` to register authorization services and construct policies |
53+
| **[ASP0026](xref:diagnostics/asp0026)** | `[Authorize]` is overridden by `[AllowAnonymous]` from "farther away" |
54+
| **[ASP0027](xref:diagnostics/asp0027)** | Unnecessary `public Program` class declaration |
55+
| **[ASP0028](xref:diagnostics/asp0028)** | Consider using `IPAddress.IPv6Any` instead of `IPAddress.Any` |
56+
| **[BL0001](xref:diagnostics/bl0001)** | Component parameter should have public setters |
57+
| **[BL0002](xref:diagnostics/bl0002)** | Component has multiple `CaptureUnmatchedValues` parameters |
58+
| **[BL0003](xref:diagnostics/bl0003)** | Component parameter with `CaptureUnmatchedValues` has the wrong type |
59+
| **[BL0004](xref:diagnostics/bl0004)** | Component parameter should be public |
60+
| **[BL0005](xref:diagnostics/bl0005)** | Component parameter shouldn't be set outside of its component |
61+
| **[BL0006](xref:diagnostics/bl0006)** | Don't use RenderTree types |
62+
| **[BL0007](xref:diagnostics/bl0007)** | Component parameter `{0}` should be auto property |
63+
| **[BL0008](xref:diagnostics/bl0008)** | Component parameters should be auto properties |
64+
| **[MVC1000](xref:diagnostics/mvc1000)** | Use of `IHtmlHelper.Partial` should be avoided |
65+
| **[MVC1001](xref:diagnostics/mvc1001)** | Filters can't be applied to page handler methods |
66+
| **[MVC1002](xref:diagnostics/mvc1002)** | Route attribute can't be applied to page handler methods |
67+
| **[MVC1003](xref:diagnostics/mvc1003)** | Route attributes can't be applied to page models |
68+
| **[MVC1004](xref:diagnostics/mvc1004)** | Rename model bound parameter |
69+
| **[MVC1005](xref:diagnostics/mvc1005)** | Can't use `UseMvc` with Endpoint Routing |
70+
| **[MVC1006](xref:diagnostics/mvc1006)** | Methods containing Tag Helpers (`TagHelpers`) must be async and return `Task` |
71+
72+
## Related content
73+
74+
- [Overview of .NET source code analysis](/dotnet/fundamentals/code-analysis/overview)

0 commit comments

Comments
 (0)