templating
templating copied to clipboard
macros 2.0
trafficstars
Problem
Macros are pain point for a while when it comes to refactoring and code understanding. I struggled a lot to write documentation for them as interfaces were very vague.
Docs effort: fixes https://github.com/dotnet/templating/issues/5028 fixes https://github.com/dotnet/templating/issues/4616
Solution
This is 7.0.2xx(?)/8.0.1xx effort.
- created better interfaces for macro component based on generics
- created base types for macro and macro config implementation that do common actions
- cleaned up the logic of macro processing
- if macro relies on other variable, and this variable doesn't exist - the processing stops
- changed logic in
GeneratePortmacro - previously macro was not releasing socket until the macro is run. Now tracking the list of assigned ports instead.
- added logging
- fixed https://github.com/dotnet/templating/issues/5028
TODO:
- [x] add doc on how to add a new macro
- [x] localization
- [x] better unit tests
Checks:
- [x] Added unit tests
- [x] Added
#nullable enableto all the modified files ?
@JanKrivanek I would like to kick of the review of this PR, though I'm still working on improving the test coverage.
The areas of review:
- new macro component interfaces - it would be good to have it pre-ready in case we start to support custom components.
- updated macro logic and improved parsing of the configuration with error handling.
- documentation
Open tasks:
- agree on coalesce behavior
- investigate bug when TemplateCreator can return
null - investigate how often
floatandhextypes are used