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
refactor(generator): transform to pure incremental source generator with DTO-based pipeline
Complete architectural transformation of Nino.Generator from hybrid incremental generator
to pure incremental source generator using only value-based DTOs. This eliminates all
ITypeSymbol dependencies in the code generation phase and implements proper multi-stage
incremental caching following Roslyn best practices.
Key Changes:
Architecture:
- Implemented 7-stage incremental pipeline with optimal caching at each stage
- Created single symbol bridge pattern in SymbolDataExtractor.cs
- Converted all metadata types to readonly record structs for value-based equality
- Replaced ITypeSymbol comparisons with TypeId-based lookups
New Infrastructure (Pipeline):
- Pipeline/SymbolDataExtractor.cs - Centralized ITypeSymbol extraction (THE ONLY symbol bridge)
- Pipeline/NinoGraphBuilder.cs - Pure DTO-based graph construction
- Metadata/CircularTypeDetector.cs - Circular reference detection using graph traversal
New Metadata DTOs:
- Metadata/TypeInfoDto.cs - Complete type information DTO
- Metadata/TypeInfoDtoExtensions.cs - Type analysis extension methods
- Metadata/TypeInfoDtoEnums.cs - Enum mappings (TypeKindDto, SpecialTypeDto, etc.)
- Metadata/ConstructorInfoDto.cs - Constructor metadata for deserialization
- Metadata/EquatableArray.cs - Value-based array wrapper for caching
- Metadata/CompilationMetadata.cs - Compilation-level metadata
Utilities:
- NinoConstants.cs - Constants (WeakVersionToleranceSymbol)
- Common/StringExtensions.cs - String utilities for code generation
- Common/CodeGeneratorExtensions.cs - Code generation helper methods
Converted to readonly record struct:
- Metadata/NinoMember.cs - Member metadata
- Metadata/NinoType.cs - Type metadata with members and constructors
- Metadata/NinoGraph.cs - Type hierarchy graph
Updated Generators (25 files):
- GlobalGenerator.cs - Completely rewritten with 7-stage pipeline
- All 5 common generators (Serializer, Deserializer, TypeConst, UnsafeAccessor, PartialClass)
- All 15 built-in type generators (Array, List, Dictionary, HashSet, Queue, Stack, etc.)
- All 3 base generator classes (NinoGenerator, NinoCommonGenerator, NinoBuiltInTypeGenerator)
Removed:
- Parser/CSharpParser.cs - Replaced by SymbolDataExtractor
- Parser/NinoTypeParser.cs - Replaced by NinoGraphBuilder
- DTOs/CompilationMetadataDto.cs - Renamed to CompilationMetadata.cs
- DTOs/TypeTransformations.cs - Logic moved to SymbolDataExtractor
Enhanced Features:
- Full constructor reflection support in DTO pipeline
- Intelligent constructor selection (NinoConstructor attribute, primary constructor, etc.)
- Pre-computed display names and instance variable names
- Support for custom serializers from external assemblies
Build Status: 0 errors, 0 warnings
Impact:
- Optimal incremental caching (only changed types trigger regeneration)
- Zero ITypeSymbol retention after extraction phase
- Value-based equality for all metadata types
- Type-safe DTO-based code generation
- Proper separation between symbol extraction and code generation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
0 commit comments