add support for renamed projects in the add reference post action#4922
Conversation
JanKrivanek
left a comment
There was a problem hiding this comment.
Thank you for the contribution!
There are couple of minor improvements needed.
Please add an explicit unit or integration test as well (it would catch issues with the current fix)
src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
Outdated
Show resolved
Hide resolved
|
I added the unit test and refined the change with your improvements. For the unit test, I needed a new Mock class; should I move this into the |
vlada-shubina
left a comment
There was a problem hiding this comment.
Thank you. We also need to update docs for this change.
src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.TemplateEngine.Cli.UnitTests/AddReferencePostActionTests.cs
Outdated
Show resolved
Hide resolved
I also took the liberty to add an example use for this post action in the documentation. |
baronfel
left a comment
There was a problem hiding this comment.
Very cool - thanks for this contribution, and double thanks for the docs example!
JanKrivanek
left a comment
There was a problem hiding this comment.
Looks good!
Thank you for the changes!
…tnet#4922) * added support for renamed projects in the add reference post action * added unit test for fixed case * refined fix to be clearer and more concise * changed fix to use GetTargetForSource * changed changekind to create in unit test * add unit case for case where referenced project was not renamed * add documentation in post action registry Co-authored-by: Robin Knoll <Robin.Knoll@world-direct.at> # Conflicts: # src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
…tnet#4922) * added support for renamed projects in the add reference post action * added unit test for fixed case * refined fix to be clearer and more concise * changed fix to use GetTargetForSource * changed changekind to create in unit test * add unit case for case where referenced project was not renamed * add documentation in post action registry Co-authored-by: Robin Knoll <Robin.Knoll@world-direct.at> # Conflicts: # src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
…tnet#4922) * added support for renamed projects in the add reference post action * added unit test for fixed case * refined fix to be clearer and more concise * changed fix to use GetTargetForSource * changed changekind to create in unit test * add unit case for case where referenced project was not renamed * add documentation in post action registry Co-authored-by: Robin Knoll <Robin.Knoll@world-direct.at> # Conflicts: # src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
…tnet#4922) * added support for renamed projects in the add reference post action * added unit test for fixed case * refined fix to be clearer and more concise * changed fix to use GetTargetForSource * changed changekind to create in unit test * add unit case for case where referenced project was not renamed * add documentation in post action registry Co-authored-by: Robin Knoll <Robin.Knoll@world-direct.at> # Conflicts: # src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
…tnet#4922) * added support for renamed projects in the add reference post action * added unit test for fixed case * refined fix to be clearer and more concise * changed fix to use GetTargetForSource * changed changekind to create in unit test * add unit case for case where referenced project was not renamed * add documentation in post action registry Co-authored-by: Robin Knoll <Robin.Knoll@world-direct.at> # Conflicts: # src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
) * added support for renamed projects in the add reference post action * added unit test for fixed case * refined fix to be clearer and more concise * changed fix to use GetTargetForSource * changed changekind to create in unit test * add unit case for case where referenced project was not renamed * add documentation in post action registry Co-authored-by: Robin Knoll <Robin.Knoll@world-direct.at> # Conflicts: # src/Microsoft.TemplateEngine.Cli/PostActionProcessors/AddReferencePostActionProcessor.cs
…tnet/templating#4922) * added support for renamed projects in the add reference post action * added unit test for fixed case * refined fix to be clearer and more concise * changed fix to use GetTargetForSource * changed changekind to create in unit test * add unit case for case where referenced project was not renamed * add documentation in post action registry Co-authored-by: Robin Knoll <Robin.Knoll@world-direct.at> Commit migrated from dotnet/templating@2876985
Problem
The post action AddReference (B17581D1-C5C9-4489-8F0A-004BE667B814) is unable to add project references if the referenced project has been renamed during template instantiation. This is because the post action does not check for renames, but only looks for the old project name.
Solution
The post action should replace the name of the referenced project in case it has been renamed. This is a similar functionality as in the targetFiles argument, where the name replacement works fine.