Skip to content

feat: FAC109 migration complexity analyzer - #410

Draft
dkattan wants to merge 5 commits into
Tim-Maes:masterfrom
dkattan:feature/fac109-migration-complexity-analyzer
Draft

dkattan wants to merge 5 commits into
Tim-Maes:masterfrom
dkattan:feature/fac109-migration-complexity-analyzer

Conversation

@dkattan

@dkattan dkattan commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Roslyn analyzer (FAC109) that scores the migration complexity of handwritten DTOs that could be replaced with Facet-generated partials. For each handwritten class that corresponds to a manifest entity, the analyzer counts entity-shaped properties, read-only properties, computed properties, and Sieve-attributed properties, then reports a diagnostic whose severity encodes the difficulty.

Changes

  • src/Facet/Analyzers/MigrationComplexityAnalyzer.cs: New analyzer that matches handwritten DTOs to manifest entities and scores migration complexity
  • test/Facet.Tests/UnitTests/Core/GenerateDtos/MigrationComplexityAnalyzerTests.cs: Comprehensive test coverage
  • devloop-fac109.sh: Development loop script for rapid iteration
  • src/Facet/AnalyzerReleases.Unshipped.md: FAC109 rule registration

Features

  • Easy (Info): All properties are get/set and match entity scalars
  • Medium (Warning): Has Sieve-attributed properties that need manual exclusion
  • Detects Create/Update request DTOs via naming conventions
  • Read-only properties are no longer a blocker (GenerateReadOnlyProperties handles init-only)
  • DateTime/DateTimeOffset detection for PropertySuffix suggestions

Split out from #408 — this analyzer depends on the EF model manifest infrastructure but is independent of the TsInterfaceName feature.

🤖 Generated with Copilot

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

dkattan and others added 3 commits July 28, 2026 10:09
Scores handwritten DTOs for Facet migration difficulty:
- Info severity: easy migration (all get/set auto-properties)
- Warning severity: needs behavior changes (read-only or computed props)

Features:
- Shadow cache (ConditionalWeakTable<Compilation, ConcurrentDictionary>)
  inspired by Vogen's BoundedCache pattern, keyed by Compilation with
  SymbolEqualityComparer for proper symbol equality
- Fail-fast: throws InvalidOperationException on unexpected manifest state
- Gratuitous logging with severity levels (DEBUG-only via Conditional attribute)
- DTO-to-entity name matching by stripping common prefixes/suffixes
- Skips entity classes themselves and already-Facet-configured types
- 10 unit tests covering easy/medium/no-diagnostic/multiple-DTO scenarios

Includes devloop-fac109.sh inner dev loop script.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…teTime detection

- Read-only properties are no longer a migration blocker (GenerateReadOnlyProperties handles init-only)
- Computed properties move to OnInitialized hook
- DateTime/DateTimeOffset detection for PropertySuffix suggestions
- Updated diagnostic messages and test expectations

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add 'RequestBody' and 'Body' to suffix list, track DtoKind (Response,
Create, Update) from prefix, adjust line savings estimate per kind,
update diagnostic message to show kind label, add per-kind configured
filtering so entities with only Response configured still surface
Create/Update candidates.

Add 3 new tests for Create/Update request DTO matching and configured
filtering.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dkattan
dkattan force-pushed the feature/fac109-migration-complexity-analyzer branch from ad5bb79 to 0ed75b7 Compare July 28, 2026 15:10
dkattan and others added 2 commits July 28, 2026 10:21
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cancel the token immediately instead of after 5ms to eliminate
a race condition on fast CI runners.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant