templating
templating copied to clipboard
changes to `IGenerator` APIs to enable validation
Solution
follow up on: https://github.com/dotnet/templating/pull/5329
Abstractions
- improved
IGeneratorAPIsIReadOnlyList<IScanTemplateInfo> GetTemplatesFromMountPoint(IMountPoint source);bool TryLoadTemplateFromTemplateInfo(IEngineEnvironmentSettings settings, ITemplateLocator config, out ITemplate? template, string? baselineName = null);
IScanTemplateInfo- new interface representing found templates during scanningITemplateLocator\IExtendedTemplateLocatorrepresenting the template to be loaded (with selected loc and host file)IValidationEntry- new interface representing generic validation entry- exposed validation errors in
ITemplateandIScanTemplateInfo
Orchestrator.RunnableProjects
To get ready for validation, the correct entry point for it is needed. TemplateConfigModel is not sufficient, as it doesn't know about template sources. RunnableProjectConfig is already overloaded.
I created an abstract intermediate layer for it: DirectoryBasedTemplate. This class will also implement validation further on.
There ate 2 implementations of DirectoryBasedTemplate
ScannedTemplateInfo- lightweight implementation containing info about all localization available. It is used as the result of template scanning but it is not ready to be run (IScanTemplateInfo). Now returns all localizations and all found host files (andEdgeis processing host files).RunnableProjectConfig- remains entry point for running the template (remainsITemplate) and holds mount point for template sources, therefore needs to be disposed.
Checks:
- [ ] Added unit tests
- [x] Added
#nullable enableto all the modified files ?
https://github.com/dotnet/templating/pull/5398/commits/cdf377e1d7d8b7fcf674e13aa819206adc5ccb18 changes APIs to be async:
- both new methods may be long running (especially scanning) and async processing may be of benefit
- validation logic will be partially async, therefore need async methods not to block the calls