You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**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
# 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 (vartriviainnode.GetLeadingTrivia())
20
+
{
21
+
if (trivia.IsKind(SyntaxKind.SingleLineCommentTrivia) &&
0 commit comments