-
Notifications
You must be signed in to change notification settings - Fork 378
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
Add PreferDefaultName property #5744
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.
Looks good!
Tests will be needed - you can add them to TemplateCreatorTests
. (after #5677 is merged, it'll be possible to add snapshot tests as well - but for now best option is TemplateCreatorTests or IDE.IntegrationTests)
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.
Looks very good, great work! Left couple of comments inline.
The following bits are missing:
- add new field to JSON schema: https://github.com/dotnet/templating/blob/main/src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Schemas/JSON/template.json (and preferably test)
- updating documentation: https://github.com/dotnet/templating/blob/main/docs/Reference-for-template.json.md#output-management
- tests (unit and integration)
src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs
Outdated
Show resolved
Hide resolved
...ne.Orchestrator.RunnableProjects.UnitTests/Serialization/TemplateConfigModelJsonConverter.cs
Outdated
Show resolved
Hide resolved
tools/Microsoft.TemplateSearch.TemplateDiscovery/Results/LegacyBlobTemplateInfo.cs
Outdated
Show resolved
Hide resolved
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.
Looks good!
Couple of comments and suggestions for additional tests.
Could you please investigate behavior: what is the error in this case: no defaultName
is specified and preferDefaultName
is set to true
? Maybe consider End2End
test.
src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/Schemas/JSON/template.json
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateSearch.Common/Abstractions/TemplateSearchData.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.TemplateEngine.TestTemplates/Microsoft.TemplateEngine.TestTemplates.csproj
Outdated
Show resolved
Hide resolved
test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs
Outdated
Show resolved
Hide resolved
…templating into defaultNameFallBack
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.
Looks solid to me - good job!
I added few comments o consider for making test code more conscise.
You can probably as well use templates test FW (via passing explicit null as name parameter).
After this is merged please create PR in schemastore to reflect your changes there as well - https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/template.json
Overall it's great!!
test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCacheTests.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt
Outdated
Show resolved
Hide resolved
test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs
Outdated
Show resolved
Hide resolved
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.
Thanks, looks good to go.
Just a small casing issue in the error message
test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateCreatorTests.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.TemplateEngine.IDE.IntegrationTests/End2EndTests.cs
Outdated
Show resolved
Hide resolved
/backport to release/7.0.2xx |
Started backporting to release/7.0.2xx: https://github.com/dotnet/templating/actions/runs/3947472630 |
@vlada-shubina backporting to release/7.0.2xx failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Base of PreferDefaultName
Using index info to reconstruct a base tree...
M src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt
M src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt
M src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs
M src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs
M src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs
M src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs
M test/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs
Falling back to patching base and 3-way merge...
Auto-merging test/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs
Auto-merging src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs
Auto-merging src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs
Auto-merging src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs
Auto-merging src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs
Auto-merging src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt
Auto-merging src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Base of PreferDefaultName
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@vlada-shubina an error occurred while backporting to release/7.0.2xx, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
Adding support for PreferDefaultName optional property in template.json Co-authored-by: Jan Krivanek <jankrivanek@microsoft.com>
Problem
This is for Issue 2303.
Solution
Adding support for
PreferDefaultName
optional property intemplate.json
. The property defines which name should be used as a fallback option when the-name
option is not passed in template creation.true
the engine will use theDefaultName
of the template.false
the engine will use the folder's name.Checks:
#nullable enable
to all the modified files ?