Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ scripts/podman.sh test
| **E128.Reference.Web** | Minimal API web app with Kestrel and a health endpoint |
| **E128.Reference.Cli** | System.CommandLine CLI with a `--name` option |
| **E128.Reference.Core** | Shared library (Greeter service, models, repositories, services) |
| **E128.Analyzers** | Roslyn analyzers (E128001 to E128226), published to nuget.org |
| **E128.Analyzers** | Roslyn analyzers (E128001 to E128231), published to nuget.org |
| **E128.Analyzers.CodeFixers** | Code fix providers for the analyzer rules, shipped in the same package |
| **E128.Reference.Tests** | xUnit v3 and MTP with the CI, Podman, and Manual test categories |
| **Architecture.Tests** | ArchUnitNET structural invariant tests (layers, naming, sealed) |
Expand Down
9 changes: 6 additions & 3 deletions lode/dotnet/analyzer-candidates/catalog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Analyzer Candidates: Settled Catalog
*Updated: 2026-11-17T23:06:12Z*
*Updated: 2026-11-18T00:04:03Z*

This file holds the settled side of the register: which rule shipped, which idea
was checked and rejected, and which sweep closed. Every rule ships from
Expand All @@ -13,8 +13,8 @@ description.

The 2026-11-05 external sweep is complete. See
[external-sweep.md](external-sweep.md).
The twenty-practice performance sweep shipped fifteen rules and leaves one
extension. See [performance-sweep.md](performance-sweep.md).
The twenty-practice performance sweep shipped fifteen rules, and its E128037
extension also ships. See [performance-sweep.md](performance-sweep.md).
The async sweep closed with no rule. See [async-sweep.md](async-sweep.md).

The implicit state machine rule ships as E128218. See
Expand Down Expand Up @@ -49,6 +49,9 @@ conversion plan. Open .NET 11 conversion shapes: [net11-conversion-sweep.md](net
| E128226 | comparer-set-by-loop | implemented | 3.5/5 | 2026-11-13 |
| E128227 | http-body-read-without-size-bound | implemented | 3.5/5 | 2026-11-13 |
| E128228 | token-validation-flag-false | implemented | n/a | 2026-11-17 |
| E128229 | middleware-func-task-next-delegate | implemented | 4/5 | 2026-11-17 |
| E128230 | static-files-runtime-pipeline | implemented | 4/5 | 2026-11-17 |
| E128231 | split-result-enumerated | implemented | 3.5/5 | 2026-11-17 |

## Rules From Guidance Documents

Expand Down
19 changes: 10 additions & 9 deletions lode/dotnet/analyzer-candidates/guidance-reads.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Guidance Document Reads
*Updated: 2026-11-17T23:06:12Z*
*Updated: 2026-11-18T00:04:03Z*

Two published guidance documents seeded a large part of the rule set. Source A
is the performance skill guide in `EgorBo/BlazingFastDotnet`. Source B is the
Expand Down Expand Up @@ -80,19 +80,20 @@ A read on 2026-11-17 checked the whole guide against the shipped rule set and
the installed analyzers. The guide covers profiling, runtime knobs, NativeAOT,
ASP.NET Core, strings, and vectorization.

Three shapes clear the bar and sit in [index.md](index.md): the `Func<Task>`
Three shapes from that read shipped as E128229 to E128231: the `Func<Task>`
middleware delegate, `UseStaticFiles`, and `string.Split` used only to
enumerate. Three more join the Tier 2 table: a per-item `Parallel.For` body, a
`FileStream` captured by a parallel body, and a `readonly` field re-read inside
a loop.
enumerate. Three more joined the Tier 2 table: a per-item `Parallel.For` body,
a `FileStream` captured by a parallel body, and a `readonly` field re-read
inside a loop.

Four shapes have an installed owner. See
[skipped-decisions.md](skipped-decisions.md).

Two extensions belong to shipped rules, not to new IDs. E128135 covers
`TensorPrimitives.Sum` only, and a `Min`, `Max`, `Add`, or `Multiply` loop is
the same shape. E128084 covers `List.GetRange` only, and an indexer loop over a
list is the shape that the open `CollectionsMarshal.AsSpan` Tier 2 row guards.
Two extensions belong to shipped rules, not to new IDs. E128135 covers a sum
loop and a min or max loop with a neutral initial value. E128084 covers
`List.GetRange` and an indexer loop over a list.
The `Add` and `Multiply` loop shapes remain open. Neither maps to a one-span
reduction, so each needs its own detection shape.

## Related

Expand Down
79 changes: 6 additions & 73 deletions lode/dotnet/analyzer-candidates/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Analyzer Candidates: Open Register
*Updated: 2026-11-17T23:06:12Z*
*Updated: 2026-11-18T00:19:04Z*

One register for every open analyzer candidate, whichever repository noticed it.
A candidate enters at status `new`, carries a four-dimension score, and leaves
Expand Down Expand Up @@ -27,16 +27,12 @@ definitions live in the `analyzer-review-miner` agent definition.

## Open Candidates

The guide below is the same source that seeded the shipped performance rules.
Every shape it lists that already has an owner stays out of this table.
The declined shapes sit in [skipped-decisions.md](skipped-decisions.md).

| Pattern | Source | Score | Status | Notes |
| ------- | ------ | ----- | ------ | ----- |
| Inline middleware takes a `Func<Task>` next delegate | BlazingFastDotnet skill guide | 4/5 | new | The `Use` overload allocates one closure per request. Detail below. |
| `UseStaticFiles()` in a minimal API app | BlazingFastDotnet skill guide | 4/5 | new | `MapStaticAssets` serves a build-time manifest. Detail below. |
| `string.Split` result only enumerated | BlazingFastDotnet skill guide | 3.5/5 | new | One array and one string per part allocate. Detail below. |
The BlazingFastDotnet guide is the same source that seeded the shipped
performance rules. Every shape it lists that already has an owner stays out of
this table. The declined shapes sit in
[skipped-decisions.md](skipped-decisions.md).

No open candidate remains from the 2026-11-17 guidance read.
`ByteSizeType.Is` matches the type by simple name, so a namespace move does not
break the E128080 exemption.

Expand All @@ -45,69 +41,6 @@ The token-validation flag shape shipped as E128228. See [catalog.md](catalog.md)
The JSON enumerator shape closed as skipped, because the enumerator releases no
resource. See [skipped-decisions.md](skipped-decisions.md).

### Inline Middleware Next Delegate

`app.Use(async (ctx, next) => ...)` binds the `Func<HttpContext, Func<Task>, Task>`
overload. That overload allocates a `Func<Task>` closure on every request.
The `Func<HttpContext, RequestDelegate, Task>` overload passes `next` as a
`RequestDelegate`, so the call allocates nothing.

```csharp
// Allocates a closure per request.
app.Use(async (context, next) =>
{
await next();
});

// Allocates nothing.
app.Use(async (context, next) =>
{
await next(context);
});
```

Detection: a `Use` call whose lambda declares a second parameter of type
`Func<Task>`. The rule reports that lambda. The `ctx` parameter must stay live
up to the `next` call, and the lambda must not reassign it.

Fix: yes. The rewrite changes the lambda call and leaves the body intact.

### Static Files Served Through the Runtime Pipeline

`app.UseStaticFiles()` sends a file through middleware at request time.
`app.MapStaticAssets()` serves a build-time manifest that carries precompressed
variants and ETags.

Detection: a `UseStaticFiles` call in a project that targets `net9.0` or later.

Fix: no automatic fix. The call moves into the endpoint mapping section, and a
Razor app also changes how it references the assets.

### `string.Split` Used Only to Enumerate

`value.Split(sep)` allocates an array and one string per part.
`MemoryExtensions.Split` yields `Range` values over the existing string.

```csharp
// Allocates the array and one string per part.
foreach (var part in line.Split(','))
{
Handle(part);
}

// Allocates nothing.
foreach (var range in line.AsSpan().Split(','))
{
Handle(line.AsSpan()[range]);
}
```

Detection: a `Split` call whose result no code stores. The separator is a
`char` or a constant string.

Fix: no automatic fix when the body stores a part as a string. The fix applies
when every read is a slice, a comparison, or a numeric parse.

## Tier 2 Candidates

These clear the same bar and wait for a real defect in review.
Expand Down
4 changes: 2 additions & 2 deletions lode/dotnet/analyzers.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# .NET 11 Roslyn Analyzers
*Updated: 2026-11-17T22:44:32Z*
*Updated: 2026-11-17T23:57:12Z*

## Strategy: Deny by Default

Expand Down Expand Up @@ -122,7 +122,7 @@ Key rules by category (not exhaustive):
| ----------- | -------------------------------------------------------------------------------------------------- |
| Design | Sealed-by-default, async void, sync-over-async, ConfigureAwait, TimeProvider, DI, ImmutableArray, abstract base with members is closed (E128225) |
| Reliability | GeneratedRegex safety, DateTime roundtrip, Task.WhenAll, JsonDocument lifetime, pool Rent() guard, stackalloc bounds, pool zeroing, service lifetime (E128154, `TryAdd`, keyed, `typeof` and `AddHostedService` forms, and a singleton `DbContext`), `foreach` mutation (E128155, including array writes and `break` or `return` exits), `TaskCompletionSource` options and shared-source completers (E128159), hand-rolled process capture (E128223, redirect, read, then wait), `Path.Combine` segments (E128161), use after `Dispose` (E128162, direct block statement only), `ImmutableArray` default (E128163, no fix for struct instance fields), `await` in `finally` (E128186), exception filter text read (E128188), unreleased `GCHandle` (E128189), hidden `GetBuffer` (E128192), disposable field overwritten in a loop (E128193), `Lazy<T>` without thread safety (E128194), configuration key absent from the settings files (E128195), `JsonSerializerOptions` written after first use (E128196), fixed day count used as a month (E128197), `Substring` count underflow (E128198) |
| Performance | MinBy/MaxBy, HttpCompletionOption, FrozenSet, O(n²) loops, `SearchValues<char>` (E128102), UTF-8 parsing, alternate lookups (E128131 to E128135), span bulk methods (E128140), u8 literals (E128141), complexity ceiling (E128152), `RemoveAt(0)` in loop (E128153), `SaveChanges` in loop (E128185), uncapped `Parallel.ForEachAsync` (E128187), `FileStream` without async I/O (E128190), HTTP and database round trips in a loop (E128203, E128204), collection presize (E128205), empty spin loop (E128206), reflection lookup in a loop (E128207), concurrent dictionary double lookup (E128208), `GetBytes` length in a loop (E128209), `new Regex` in a loop (E128210), `Task.Delay` in a loop without a token (E128211), `ToCharArray` copy (E128212), `Activator` in a loop (E128213), handler without decompression (E128214), `StringBuilder` capacity (E128215), unbounded channel (E128216), large struct by value (E128217), read-only `MemoryStream` (E128224), comparer set filled by a loop (E128226) |
| Performance | MinBy/MaxBy, HttpCompletionOption, FrozenSet, O(n²) loops, `SearchValues<char>` (E128102), UTF-8 parsing, alternate lookups (E128131 to E128135), span bulk methods (E128140), u8 literals (E128141), complexity ceiling (E128152), `RemoveAt(0)` in loop (E128153), `SaveChanges` in loop (E128185), uncapped `Parallel.ForEachAsync` (E128187), `FileStream` without async I/O (E128190), HTTP and database round trips in a loop (E128203, E128204), collection presize (E128205), empty spin loop (E128206), reflection lookup in a loop (E128207), concurrent dictionary double lookup (E128208), `GetBytes` length in a loop (E128209), `new Regex` in a loop (E128210), `Task.Delay` in a loop without a token (E128211), `ToCharArray` copy (E128212), `Activator` in a loop (E128213), handler without decompression (E128214), `StringBuilder` capacity (E128215), unbounded channel (E128216), large struct by value (E128217), read-only `MemoryStream` (E128224), comparer set filled by a loop (E128226), middleware `Func<Task>` next delegate (E128229), static files through the runtime pipeline (E128230), split result enumerated without a stored array (E128231) |
| Security | FIPS cryptography rules: unapproved hash names, `System.Random` in security code, managed and CNG type creation, RSA key size, cipher mode, PBKDF2 work factor, TLS versions, deprecated RNG, excluded cipher names, AES-GCM tag size, SHA-3 policy, HMAC key length (E128071, E128075, E128142 to E128151), certificate bypass (E128156, `SslOptions` and `SslStream` too), fixed-time compare (E128157), hardcoded URL (E128164, dot boundary), hardcoded secret (E128165, token, credential and bearer names, `??`, indexers, getter returns, `u8`, connection strings), sensitive log argument (E128166, `LoggerMessage`, wrapped args, whole-word `ssn` and `pwd`, skips `EventId` and `Exception`), PFX import without `EphemeralKeySet` (E128191), unvalidated JWT claims used as an identity (E128202), token validation flag pinned false (E128228) |
| Unsafe | `Unsafe.As` to `Unsafe.BitCast`, unaligned reads, unaligned non-blittable reads (E128139), bounds bypass, bool and int reinterpret, non-blittable `MemoryMarshal`, fixed buffers, `SkipInit`, unpinned pointers, string writes, null byref, delegate lifetime, bulk copy, pointer and length pairs, nonpublic reflection, raw IL, function pointer types (E128112 to E128129, E128136 to E128139, E128200) |
| Style | string.Empty, Encoding.UTF8, XML doc comments, null-forgiving operator |
Expand Down
59 changes: 59 additions & 0 deletions lode/dotnet/analyzers/rule-details-performance-aspnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Performance Rule Details: ASP.NET Core
*Updated: 2026-11-17T23:58:14Z*

Detection shape for the ASP.NET Core allocation rules E128229 to E128231. The
rest of the performance rules live in
[rule-details-performance.md](rule-details-performance.md). Each rule gates on
the API that supplies its remedy, so a compilation without ASP.NET Core gets no
report.

### E128229: Middleware next delegate closure

Flags an inline `Use` middleware whose second parameter is `Func<Task>`. The
`Func<HttpContext, Func<Task>, Task>` overload allocates a `Func<Task>` closure
per request. The `RequestDelegate` overload passes the same delegate with no
allocation.

The rule resolves `IApplicationBuilder` and `UseMiddlewareExtensions`, then
checks the delegate type by symbol. It reports the second parameter only when
every use of `next` is a call with no argument, at least one call exists, and
the context parameter carries no assignment.

The code fix writes `RequestDelegate` in the parameter type position, passes the
context to every call, and adds `Microsoft.AspNetCore.Http` when the file lacks
it.

### E128230: Static files through the runtime pipeline

Flags a zero-argument `UseStaticFiles` call. `MapStaticAssets` serves a
build-time manifest with precompressed variants and ETags.

The rule registers only when the compilation declares `MapStaticAssets`, which
gates the rule to a target framework with the endpoint mapping API. The symbol
must belong to `StaticFileExtensions`. A call that passes `StaticFileOptions`
stays silent. No code fix, because the call moves into the endpoint mapping
section and a Razor app also changes how it references the assets.

### E128231: Split result used only to enumerate

Flags a `foreach` over `string.Split` with a `char` or constant-string separator
and the default split options. `MemoryExtensions.Split` yields `Range` values
over the source with no array and no part strings.

The rule registers only when `MemoryExtensions` declares the span `Split`
extension. It reports the loop. The fix applies when the receiver is a name
chain and every read of the part is a length, an element access, or a
constant-string comparison. The fix enumerates `source.AsSpan().Split(separator)`
and reads each part as `source.AsSpan()[range]`.

A numeric parse stays reported with no fix. The narrowest `Parse` overload for
`ReadOnlySpan<char>` also takes an `IFormatProvider`, so the rewrite would add a
culture decision that the loop does not state.

## Related

- [rule-details-performance.md](rule-details-performance.md): the earlier
performance rules and the E128135 and E128084 extensions
- [rule-details-performance-tier2.md](rule-details-performance-tier2.md): the
waiting Tier 2 performance rules
- [rule-details.md](rule-details.md): the remaining rule details
16 changes: 15 additions & 1 deletion lode/dotnet/analyzers/rule-details-performance.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Performance Rule Details
*Updated: 2026-11-09T23:44:15Z*
*Updated: 2026-11-17T23:58:14Z*

Behavior notes for the performance rules. The complete rule table, the
severity, and the code-fix status live in `src/E128.Analyzers/README.md`. The
Expand Down Expand Up @@ -207,6 +207,20 @@ per-iteration values.
No code fix. The hoisted field name and the `GeneratedRegex` shape are caller
choices.

### E128135 and E128084 extensions

E128135 also reports a minimum or maximum loop over a `float` or `double`
source. The reduction must start at the neutral value: `MinValue` for a maximum
and `MaxValue` for a minimum. The fix writes the reduction into the accumulator
declaration and removes the loop.

E128084 also reports `for (int i = 0; i < list.Count; i++)` when the body only
reads `list[i]`. The rule suppresses a loop that mutates the list, writes
through the indexer, or uses the loop variable for another purpose. The fix
enumerates `CollectionsMarshal.AsSpan(list)`.

ASP.NET Core rules E128229 to E128231 live in
[rule-details-performance-aspnet.md](rule-details-performance-aspnet.md).
Tier 2 rules E128211 to E128217 live in
[rule-details-performance-tier2.md](rule-details-performance-tier2.md).

Expand Down
3 changes: 2 additions & 1 deletion lode/dotnet/release-tracking.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Roslyn Analyzer Release Tracking
*Updated: 2026-11-17T22:56:03Z*
*Updated: 2026-11-18T00:22:59Z*

## Overview

Expand Down Expand Up @@ -171,6 +171,7 @@ that is missing from either file blocks the ship, even on a docs-only change set
| 3.0.0 | (none) | E128160 removed. E128223 reports the read-then-wait shape that replaced the hand-rolled process capture. |
| 3.1.0 | E128227 | HTTP body read without a size bound. Security, Warning. |
| 3.2.0 | E128228 | Token validation flag set to constant false. Security, Warning. |
| 3.3.0 | E128229-231 | Middleware next delegate, static assets, and split enumeration. E128135 and E128084 gain a second detection shape. |

## Sources

Expand Down
3 changes: 2 additions & 1 deletion lode/lode-map.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Lode Map
*Updated: 2026-11-17T23:06:12Z*
*Updated: 2026-11-17T23:58:14Z*

## Generated Docs

Expand Down Expand Up @@ -69,6 +69,7 @@
- [rule-details.md](dotnet/analyzers/rule-details.md): Per-rule detection shape, exclusions, and code-fix behavior for the E128 rules
- [rule-details-performance.md](dotnet/analyzers/rule-details-performance.md): Detection shape for performance rules E128203 to E128210
- [rule-details-performance-tier2.md](dotnet/analyzers/rule-details-performance-tier2.md): Detection shape for performance rules E128211 to E128217
- [rule-details-performance-aspnet.md](dotnet/analyzers/rule-details-performance-aspnet.md): Detection shape for ASP.NET Core performance rules E128229 to E128231
- [rule-details-reliability.md](dotnet/analyzers/rule-details-reliability.md): Detection shape for the reliability rules
- [rule-details-reliability-concurrency.md](dotnet/analyzers/rule-details-reliability-concurrency.md): Detection shape for the async and concurrent reliability rules
- [rule-details-reliability-resources.md](dotnet/analyzers/rule-details-reliability-resources.md): Detection shape for the resource lifetime and shared state rules
Expand Down
Loading