Skip to content
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 RemoveDependency method to DependencyFileManager #4405

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dkurepa
Copy link
Member

@dkurepa dkurepa commented Jan 31, 2025

#4390
Adds a RemoveDependencyAsync method with the same API as AddDependencyAsync

@dkurepa dkurepa requested review from Copilot, premun and adamzip January 31, 2025 13:10

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/Microsoft.DotNet.Darc/DarcLib/Helpers/DependencyFileManager.cs:243

  • [nitpick] The error message 'Couldn't find dependency {dependency.Name} in Version.props' could be more descriptive. Consider changing it to 'Dependency {dependency.Name} not found in Version.props. Ensure the dependency name is correct and exists in the file.'
throw new DependencyException("Couldn't find dependency {dependency.Name} in Version.props");

src/Microsoft.DotNet.Darc/DarcLib/Helpers/DependencyFileManager.cs:258

  • [nitpick] The error message 'Dependency {dependency.Name} not found in Version.Details.xml' could be more descriptive. Consider changing it to 'Dependency {dependency.Name} not found in Version.Details.xml. Ensure the dependency name is correct and exists in the file.'
throw new DependencyException("Dependency {dependency.Name} not found in Version.Details.xml");
@dkurepa dkurepa marked this pull request as ready for review January 31, 2025 13:30
@@ -211,6 +211,57 @@ public async Task AddDependencyAsync(
await AddDependencyToVersionDetailsAsync(repoUri, branch, dependency);
}

public async Task RemoveDependencyAsync(DependencyDetail dependency, string repoUri, string branch)
Copy link
Member

Choose a reason for hiding this comment

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

How about the dotnet tool config? Would that also be easy to do too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll check

Copy link
Member Author

Choose a reason for hiding this comment

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

Added it

premun
premun previously approved these changes Feb 4, 2025
Comment on lines 240 to 256
if (dotnetTools != null)
{
var tools = dotnetTools["tools"] as JObject;
if (tools != null)
{
// we have to do this because JObject is case sensitive
var toolProperty = tools.Properties().FirstOrDefault(p => p.Name.Equals(dependency.Name, StringComparison.OrdinalIgnoreCase));
if (toolProperty != null)
{
tools.Remove(toolProperty.Name);
}

return dotnetTools;
}
}

return null;
Copy link
Member

Choose a reason for hiding this comment

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

Can we swap the if and reduce nesting?

Copy link
Member Author

Choose a reason for hiding this comment

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

done, VS also did some fancy pattern matching stuff

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.

2 participants