Refactor code templates processing, move more to compiled#33
Conversation
4ee20c2 to
91deeaf
Compare
🧪 Details on macOS Unix 14.7.1✅ StructId.CodeTemplateTests.AddsStructIdNamespace 🧪 Details on Ubuntu 22.04.5 LTS✅ StructId.CodeTemplateTests.AddsStructIdNamespace 🧪 Details on Microsoft Windows 10.0.20348✅ StructId.CodeTemplateTests.AddsStructIdNamespace from dotnet-retest v0.6.3 on .NET 8.0.11 with 💜 |
Refactor resource and compiled templates to use a unified CodeTemplate implementation that simplifies the application of a template for a given target struct id. This allowed to also simplify quite a bit the tests. Most templates are now simple compiled ones, except for the ones that need custom logic that isn't just checking target value type (TId) compatiblity. In particular: ctor generation is dynamic since users can provide their own ctor, so we can't just apply them as compiled templates. EF, Dapper and Newtonsoft.Json need conditional checking on type presense, so they cannot be ported either. Regardless, we now have a single unified way of authoring templates for either scenario. This infolves using always file-only types, which removes cross-template dependencies we had with a hardcoded TSelf/TId pair.
Refactor resource and compiled templates to use a unified CodeTemplate implementation that simplifies the application of a template for a given target struct id.
This allowed to also simplify quite a bit the tests.
Most templates are now simple compiled ones, except for the ones that need custom logic that isn't just checking target value type (TId) compatiblity.
In particular: ctor generation is dynamic since users can provide their own ctor, so we can't just apply them as compiled templates.
EF, Dapper and Newtonsoft.Json need conditional checking on type presense, so they cannot be ported either.
Regardless, we now have a single unified way of authoring templates for either scenario. This infolves using always file-only types, which removes cross-template dependencies we had with a hardcoded TSelf/TId pair.