-
Notifications
You must be signed in to change notification settings - Fork 76
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
base: main
Are you sure you want to change the base?
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.
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");
@@ -211,6 +211,57 @@ public async Task AddDependencyAsync( | |||
await AddDependencyToVersionDetailsAsync(repoUri, branch, dependency); | |||
} | |||
|
|||
public async Task RemoveDependencyAsync(DependencyDetail dependency, string repoUri, string branch) |
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.
How about the dotnet tool config? Would that also be easy to do too?
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.
I'll check
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.
Added it
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; |
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.
Can we swap the if
and reduce nesting?
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.
done, VS also did some fancy pattern matching stuff
#4390
Adds a
RemoveDependencyAsync
method with the same API asAddDependencyAsync