-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Component-based template validation PoC #5838
Component-based template validation PoC #5838
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great!
IReadOnlyList<ScannedTemplateInfo> foundTemplates = Task.Run(async () => await GetTemplatesFromMountPointInternalAsync(source, default).ConfigureAwait(false)).GetAwaiter().GetResult(); | ||
localizations = foundTemplates.SelectMany(t => t.Localizations.Values).ToList(); | ||
IReadOnlyList<ScannedTemplateInfo> foundTemplates = | ||
Task.Run(async () => await GetTemplatesFromMountPointInternalAsync(source, default).ConfigureAwait(false)).GetAwaiter().GetResult(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is "better than nothing" attempt to avoid deadlock (we used to have them with XUnit).
Running anything in threadpool ensures no context, therefore less chance for deadlocks.
This is based on https://learn.microsoft.com/en-us/archive/msdn-magazine/2015/july/async-programming-brownfield-async-development#the-thread-pool-hack and https://devblogs.microsoft.com/pfxteam/should-i-expose-synchronous-wrappers-for-asynchronous-methods/?WT.mc_id=DT-MVP-5000058 and so far I haven't seen better alternative.
...rosoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/SchemaTests/JSONSchemaTests.cs
Show resolved
Hide resolved
internal enum ValidationScope | ||
{ | ||
None = 0, | ||
Scanning = 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is "Scanning" for installed templates?
what does it mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check is run when scanning the mount point for templates, typically installation or scanning scenario by 3rd party tools scenario. Calling it installation is somewhat wrong, as we expose API to scan templates, therefore I ended up with scanning.
I added documentation to those members.
// Localizations provide more translations than the number of manual instructions we have. | ||
string excessInstructionLocalizationIds = string.Join( | ||
", ", | ||
postActionLocModel.Instructions.Keys.Where(k => !postAction.ManualInstructionInfo.Any(i => i.Id == k))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible that we have a lot of concatenations here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. This is existing code (now in
templating/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/RunnableProjectConfig.cs
Line 306 in 4fe046d
string excessInstructionLocalizationIds = string.Join( |
looks good to me ! |
* poc * logging validation messages * changes after review * added missing localization
* poc * logging validation messages * changes after review * added missing localization
Problem
#2623
Solution
Component-based template validation.
Note: the design done under assumption that
ITemplateValidator
andITemplateValidatorFactory
becomes public later on and any host or tool can create more validator components and inject the checks.Note: current validation checks are only those which existed before, and serve as example. More checks to be added later on.
TODO:
Checks:
#nullable enable
to all the modified files ?