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
11 changes: 8 additions & 3 deletions lode/dotnet/analyzers/rule-details-conversion.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Conversion Rules E128223 to E128226
*Updated: 2026-11-14T01:26:59Z*
*Updated: 2026-11-16T15:41:36Z*

Detection shape for the .NET 11 conversion family. The rules move working code onto a
mechanism the band carries. Sources: [net11-conversion-sweep.md](../analyzer-candidates/net11-conversion-sweep.md).
Expand Down Expand Up @@ -34,7 +34,8 @@ or a statement-form flag set on a start-info local that later reaches a process
## E128224: Read-Only MemoryStream

Reports `new MemoryStream(x)` in a local when `x` is an `Encoding.GetBytes` result or a
`byte[]`, and every use of the local is read shaped. Read shaped means one of:
`byte[]`, and every use of the local is read shaped. The target-typed `new(x)` form
counts too. Read shaped means one of:

- A member call in the read set (`Read`, `ReadAsync`, `CopyTo`, `Seek`, `Dispose`, and
similar).
Expand All @@ -43,6 +44,9 @@ Reports `new MemoryStream(x)` in a local when `x` is an `Encoding.GetBytes` resu
`XPathDocument`, `XmlReader.Create`, `JsonDocument.Parse`, `XDocument.Load`,
`HashAlgorithm.ComputeHash`).

A settable member read is a read only when the syntax reads it. An assignment, an
increment, or a `ref` argument to a member such as `Position` is a write.

A compression wrapper (`GZipStream`, `DeflateStream`, `BrotliStream`) counts as a
read consumer only when the creation passes `CompressionMode.Decompress`
(`IsDecompressMode` resolves the field symbol). A compress-mode or mode-less
Expand All @@ -65,7 +69,8 @@ compiler rejects only the `closed abstract` modifier pair on the type.

## E128226: Comparer Set Built By A Loop

Reports `new HashSet<T>(comparer)` in a local when:
Reports `new HashSet<T>(comparer)` in a local when the creation is target typed
(`HashSet<T> set = new(comparer)`) or explicit, and:

1. The creation has no collection initializer.
2. The argument implements `IEqualityComparer<T>`.
Expand Down
7 changes: 6 additions & 1 deletion lode/dotnet/analyzers/rule-details-reliability.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reliability Rule Details
*Updated: 2026-11-14T01:26:59Z*
*Updated: 2026-11-16T15:41:36Z*

Behavior notes for the reliability rules. The complete rule table, the
severity, and the code-fix status live in `src/E128.Analyzers/README.md`. The
Expand Down Expand Up @@ -163,6 +163,11 @@ silent. A group that leads with a distinct separator atom, such as
`(?:/[^/]+)+`, also stays silent: `FirstAtomCanAlsoBeLast` exempts it when
the first and last consuming atoms cannot match the same text.

The code fix rewrites a single-atom body only. It removes the outer quantifier,
or makes the group non-capturing when removal would lose the empty match. A
multi-atom body has no language-preserving rewrite that clears the report, so
the fixer offers no action for that shape.

Both scans treat character class contents as literals. `BuildCharacterClassMask`
marks every index inside a `[...]` class in one pass, and each scan skips masked
indices. The mask handles a leading `^`, a leading literal `]`, and escapes. A
Expand Down
11 changes: 6 additions & 5 deletions lode/dotnet/analyzers/rule-details-security.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Security Rule Detail Notes
*Updated: 2026-11-16T15:18:25Z*
*Updated: 2026-11-16T15:41:36Z*

Detection shape and exclusions for the E128 security rules that the main rule
table cannot show. The severity and the code-fix status live in
Expand Down Expand Up @@ -30,10 +30,11 @@ name text:
- A local whose initializer is a `ContentLength` access on the same chain
counts as the bound variable.

A `MaxResponseContentBufferSize` reference anywhere in the enclosing type also
bounds every read in that type. This covers a typed client that configures its
own handler. A bound in a different type is invisible, so a client configured in
a composition root needs an analyzer suppression at the read site.
A `MaxResponseContentBufferSize` setting does not bound a direct content read.
The setting caps the client buffer only, so a read through
`HttpContent.ReadAsStringAsync` stays unbounded. A bound in a different method or
type is invisible, so a client configured in a composition root needs a bound in
the read scope or an analyzer suppression at the read site.

An in-memory content type needs no bound: `ByteArrayContent`, its derived
`StringContent` and `FormUrlEncodedContent`, `ReadOnlyMemoryContent`, and
Expand Down
73 changes: 0 additions & 73 deletions plans/review-2026-11-14-general/general-context.md

This file was deleted.

70 changes: 0 additions & 70 deletions plans/review-2026-11-14-general/general-plan.md

This file was deleted.

14 changes: 0 additions & 14 deletions plans/review-2026-11-14-general/general-tasks.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ protected override Task RegisterFixesAsync(CodeFixContext context, SyntaxNode ro
// A single-atom body makes the outer quantifier redundant, so the rewrite removes it
// and the diagnostic clears. When removing the outer quantifier would lose the empty
// match, like '(a+)*', the rewrite keeps it and makes the group non-capturing, so the
// language stays. The diagnostic stays in that case. Any other body keeps the
// language with an equivalent unbounded brace repeat. An unbounded brace outer
// quantifier has no language-preserving one-token rewrite and stays flagged.
// language stays. The diagnostic stays in that case. A multi-atom body has no
// language-preserving rewrite that clears the diagnostic: '(x){1,}' still carries the
// nested quantifier, so no fix is offered.
internal static string RewriteOuterQuantifier(string pattern)
{
if (GeneratedRegexHelpers.FindNestedQuantifierSpan(pattern) is not { } span)
Expand All @@ -52,19 +52,17 @@ internal static string RewriteOuterQuantifier(string pattern)
return pattern;
}

if (span.SingleAtomBody)
if (!span.SingleAtomBody)
{
if (RemovalKeepsLanguage(pattern, span))
{
return pattern.Remove(quantifierIndex, span.QuantifierLength);
}
return pattern;
}

return MakeGroupNonCapturing(pattern, span);
if (RemovalKeepsLanguage(pattern, span))
{
return pattern.Remove(quantifierIndex, span.QuantifierLength);
}

var lazy = span.QuantifierLength > 1 && pattern[quantifierIndex + 1] is '?';
var replacement = string.Concat(pattern[quantifierIndex] is '*' ? "{0,}" : "{1,}", lazy ? "?" : string.Empty);
return pattern.Substring(0, quantifierIndex) + replacement + pattern.Substring(quantifierIndex + span.QuantifierLength);
return MakeGroupNonCapturing(pattern, span);
}

// Removing the outer quantifier keeps the language unless the outer quantifier is a
Expand Down
2 changes: 1 addition & 1 deletion src/E128.Analyzers/E128.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<!-- NuGet Packaging -->
<PropertyGroup>
<Version>3.1.2</Version>
<Version>3.1.3</Version>
<IsPackable>true</IsPackable>
<IncludeBuildOutput>false</IncludeBuildOutput>
<DevelopmentDependency>true</DevelopmentDependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ public override void Initialize(AnalysisContext context)

context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.EnableConcurrentExecution();
context.RegisterSyntaxNodeAction(AnalyzeCreation, SyntaxKind.ObjectCreationExpression);
context.RegisterSyntaxNodeAction(
AnalyzeCreation,
SyntaxKind.ObjectCreationExpression,
SyntaxKind.ImplicitObjectCreationExpression);
}

private static void AnalyzeCreation(SyntaxNodeAnalysisContext context)
{
var creation = (ObjectCreationExpressionSyntax)context.Node;
var creation = (BaseObjectCreationExpressionSyntax)context.Node;
var model = context.SemanticModel;
var cancellationToken = context.CancellationToken;

Expand All @@ -88,7 +91,7 @@ private static void AnalyzeCreation(SyntaxNodeAnalysisContext context)
}

private static bool IsComparerHashSet(
ObjectCreationExpressionSyntax creation,
BaseObjectCreationExpressionSyntax creation,
SemanticModel model,
CancellationToken cancellationToken)
{
Expand All @@ -110,7 +113,7 @@ private static bool HasEqualityComparerArgument(
}

private static ILocalSymbol? GetTargetLocal(
ObjectCreationExpressionSyntax creation,
BaseObjectCreationExpressionSyntax creation,
SemanticModel model,
CancellationToken cancellationToken)
{
Expand Down
Loading