Skip to content

Commit 99349b0

Browse files
csharpfritzCopilot
andcommitted
docs: update cyclops history and add advisory code fix decision
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 928694b commit 99349b0

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

.squad/agents/cyclops/history.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,3 +587,31 @@ Replaced XDocument-based ASPX parser with AngleSharp for tolerant HTML5 parsing
587587

588588

589589
📌 Team update (2026-03-20): Rogue fixed code fix trivia bugs in BWFC002/003 (and authored BWFC004/005). Issue: EmptyStatement code fixes placed semicolons immediately after // comments, causing parse failures. Solution: Add EndOfLine trivia after comments before semicolon. Pattern now applied to all BWFC code fix providers (decision merged to decisions.md). All 54 tests passing.
590+
591+
### BWFC010 & BWFC011 Roslyn Analyzers (2026-07-25)
592+
593+
**Summary:** Built two BWFC Usage Validation analyzers with code fixes and full test coverage. All 89 analyzer tests passing.
594+
595+
**BWFC010 — Required Attribute Missing on BWFC Component:**
596+
- Registers for SyntaxKind.ObjectCreationExpression, detects
597+
ew GridView<T>(),
598+
ew HyperLink(),
599+
ew Image() without critical property assignment
600+
- Checks both object initializer assignments (
601+
ew GridView<T> { DataSource = ... }) and subsequent member access assignments (grid.DataSource = ...)
602+
- Verifies type resolves to BlazorWebFormsComponents namespace via IsBwfcType() walk up the type hierarchy
603+
- Severity: Info (guidance, not errors)
604+
- Code fix adds TODO comment suggesting the missing attribute
605+
- 9 tests (4 positive, 5 negative)
606+
607+
**BWFC011 — Web Forms Event Handler Signature Detected:**
608+
- Registers for SyntaxKind.MethodDeclaration, detects methods with exactly 2 params where first is object and second type name ends with EventArgs
609+
- Only fires when containing class derives from ComponentBase, WebControl, CompositeControl, BaseWebFormsComponent, BaseStyledComponent, or WebFormsPageBase
610+
- Severity: Info
611+
- Code fix adds TODO comment; made idempotent by checking existing leading trivia for TODO before re-adding
612+
- 8 tests (3 positive, 4 negative, 1 code fix)
613+
614+
**Key patterns learned:**
615+
- For "advisory" code fixes that don't remove the diagnostic, the code fix MUST be idempotent (check if TODO already exists in trivia before adding) — otherwise the test framework's iterative application creates duplicates
616+
- Code fix tests with persistent diagnostics require FixedState.ExpectedDiagnostics + NumberOfIncrementalIterations = 2 + NumberOfFixAllIterations = 2 to account for apply-once-then-converge behavior
617+
- RequiredProperties dictionary pattern (type name → required property names) is extensible for future BWFC components
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Decision: Idempotent Code Fixes for Advisory Analyzers
2+
3+
**Author:** Cyclops
4+
**Date:** 2026-07-25
5+
**Context:** BWFC010/BWFC011 implementation
6+
7+
## Decision
8+
9+
When a Roslyn code fix adds a TODO comment but does NOT remove the underlying diagnostic (advisory/Info-severity analyzers), the code fix **must be idempotent** — check for existing TODO in leading trivia before adding.
10+
11+
## Rationale
12+
13+
The Roslyn test framework (and IDE) applies code fixes iteratively until convergence. If a fix adds a comment but the diagnostic persists, the fix runs again. Without an idempotency guard, duplicates accumulate.
14+
15+
## Pattern
16+
17+
```csharp
18+
// In code fix provider, before adding TODO:
19+
foreach (var trivia in node.GetLeadingTrivia())
20+
{
21+
if (trivia.IsKind(SyntaxKind.SingleLineCommentTrivia) &&
22+
trivia.ToString().Contains("TODO: <unique marker>"))
23+
return document; // Already applied
24+
}
25+
```
26+
27+
Test configuration for persistent diagnostics:
28+
```csharp
29+
FixedState = { ExpectedDiagnostics = { ... } },
30+
NumberOfIncrementalIterations = 2,
31+
NumberOfFixAllIterations = 2,
32+
```
33+
34+
## Scope
35+
36+
Applies to all future BWFC analyzers at Info severity where the code fix doesn't resolve the diagnostic.

0 commit comments

Comments
 (0)