Skip to content

add support for renamed projects in the add reference post action#4922

Merged
vlada-shubina merged 7 commits intodotnet:mainfrom
knollsen:feature/fix_postaction_add_project_reference
Jul 12, 2022
Merged

add support for renamed projects in the add reference post action#4922
vlada-shubina merged 7 commits intodotnet:mainfrom
knollsen:feature/fix_postaction_add_project_reference

Conversation

@knollsen
Copy link
Copy Markdown
Contributor

@knollsen knollsen commented Jul 5, 2022

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.

@knollsen knollsen requested a review from a team as a code owner July 5, 2022 11:09
@dnfadmin
Copy link
Copy Markdown

dnfadmin commented Jul 5, 2022

CLA assistant check
All CLA requirements met.

Copy link
Copy Markdown
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@knollsen
Copy link
Copy Markdown
Contributor Author

knollsen commented Jul 11, 2022

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 Microsoft.TemplateEngine.Mocks project or leave it where it is? It's currently a private nested class in the unit test class for the post action processor.

Copy link
Copy Markdown
Member

@vlada-shubina vlada-shubina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. We also need to update docs for this change.

@knollsen knollsen requested a review from baronfel as a code owner July 11, 2022 20:33
@knollsen
Copy link
Copy Markdown
Contributor Author

Thank you. We also need to update docs for this change.

I also took the liberty to add an example use for this post action in the documentation.

Copy link
Copy Markdown
Member

@baronfel baronfel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool - thanks for this contribution, and double thanks for the docs example!

@knollsen knollsen requested a review from JanKrivanek July 12, 2022 05:41
Copy link
Copy Markdown
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Thank you for the changes!

@vlada-shubina vlada-shubina merged commit 2876985 into dotnet:main Jul 12, 2022
@knollsen knollsen deleted the feature/fix_postaction_add_project_reference branch July 12, 2022 16:48
vlada-shubina pushed a commit to vlada-shubina/templating that referenced this pull request Aug 23, 2022
…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
vlada-shubina pushed a commit to vlada-shubina/templating that referenced this pull request Aug 23, 2022
…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
vlada-shubina pushed a commit to vlada-shubina/templating that referenced this pull request Aug 23, 2022
…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
vlada-shubina pushed a commit to vlada-shubina/templating that referenced this pull request Aug 23, 2022
…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
vlada-shubina pushed a commit to vlada-shubina/templating that referenced this pull request Aug 23, 2022
…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
vlada-shubina pushed a commit that referenced this pull request Sep 7, 2022
)

* 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
mmitche pushed a commit to dotnet/sdk that referenced this pull request Apr 2, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants