Skip to content

refactor(cli): split TemplateEngine into focused single-responsibility services#1202

Merged
iammukeshm merged 1 commit intodevelopfrom
refactor/split-template-engine
Feb 2, 2026
Merged

refactor(cli): split TemplateEngine into focused single-responsibility services#1202
iammukeshm merged 1 commit intodevelopfrom
refactor/split-template-engine

Conversation

@iammukeshm
Copy link
Member

Summary

Split the 1645-line TemplateEngine god class into focused single-responsibility services.

Changes

New Services

  • ITemplateLoader/TemplateLoader: Load templates from embedded resources
  • ITemplateParser/TemplateParser: Parse template syntax and normalize names
  • ITemplateRenderer/TemplateRenderer: Render templates with variable substitution
  • ITemplateValidator/TemplateValidator: Validate templates and project options
  • ITemplateCache/TemplateCache: Cache frequently used templates
  • TemplateServices: DI container for service management

Benefits

  • ✅ Single Responsibility Principle - each class has one job
  • ✅ Better testability with focused, mockable interfaces
  • ✅ Improved maintainability and extensibility
  • ✅ Built-in validation with detailed error messages
  • ✅ Template caching for better performance
  • ✅ Full backward compatibility - no API changes

Technical Notes

  • Original TemplateEngine.cs backed up for reference
  • Added Microsoft.Extensions.DependencyInjection dependency
  • Created comprehensive interfaces and implementations
  • Added validation tests and documentation

Closes #1181

BREAKING: None - maintains full backward compatibility

Split the 1645-line TemplateEngine god class into focused services:

- ITemplateLoader/TemplateLoader: Load templates from resources
- ITemplateParser/TemplateParser: Parse template syntax and normalize names
- ITemplateRenderer/TemplateRenderer: Render templates with variable substitution
- ITemplateValidator/TemplateValidator: Validate templates and project options
- ITemplateCache/TemplateCache: Cache frequently used templates
- TemplateServices: DI container for service management

Benefits:
✅ Single Responsibility Principle
✅ Better testability with focused classes
✅ Improved maintainability and extensibility
✅ Built-in validation with detailed error messages
✅ Template caching for better performance
✅ Full backward compatibility - no API changes

Files:
- Backed up original TemplateEngine.cs
- Added Microsoft.Extensions.DependencyInjection dependency
- Created comprehensive interfaces and implementations
- Added validation tests and documentation

Resolves: #1181
@iammukeshm iammukeshm merged commit 039bd18 into develop Feb 2, 2026
8 checks passed
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.

[Refactor] Split CLI TemplateEngine.cs (1645 lines)

1 participant