Warn for http when used in source commands#4600
Conversation
|
Have we considered adding it to the list itself so that the warning is visible when the source isn't selected? |
|
The control is currently WinForms, with a custom renderer for each list item, so it's quite complex to change. I don't know how easy it would be to port this to WPF, which would make it a lot easier. |
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourcesOptionsControl.cs
Outdated
Show resolved
Hide resolved
|
I think we should split this PR into two. One PR for CLI experience and other one for VS experience. Looking at the screenshots in the PR description, I think it only addresses one scenario when user edits the URI scheme to HTTP. I think we should also consider displaying a warning icon next to the package source if it's URI Scheme is HTTP. Tagging @JonDouglas for inputs on VS experience. |
|
Removed the UI changes and only left CLI changes |
|
@NuGet/nuget-client |
@martinrrm - This PR doesn't seem to affect the VS options dialog, so I disagree that it will fix the issue # 1154 |
|
We were capturing general scenarios for raising warnings. We want to do it all anyways. I didn't want to create 2 or 3 different issues myself, as I didn't want to guess how many PRs these changes would take (by extension how many issues).
it's on @martinrrm as the issue assignee and PR author to ensure he has an issue for each PR as needed. He can make that issue an epic and list 2-3 different issues, or he can just create one new issue and convert that particular issue back to a VS Options dialog specific. |
donnie-msft
left a comment
There was a problem hiding this comment.
Nice! Just a few suggestions...
test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetSourcesCommandTest.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetSourcesCommandTest.cs
Outdated
Show resolved
Hide resolved
|
For what is worth, I also added a comment when I changed the scope of the issue https://github.com/NuGet/Client.Engineering/issues/1154#issuecomment-1082259969 |
|
@martinrrm based on Nikolche's response, I went ahead and restored 1154 back to being VS Options focused. Please create a new GH issue for the CLI side, and make this PR resolve it rather than the VS one. Thanks |
|
@donnie-msft Thanks for the review! About the issue, I decided to separate it into two PRs, thank you for updating the PRs title. New issue: https://github.com/NuGet/Client.Engineering/issues/1622 |
3c4d5d3 to
335c38f
Compare
b5ad3c9 to
1492e08
Compare
| var sourceItem = packageSourcesSection?.GetFirstItemWithAttribute<SourceItem>("key", "test_source"); | ||
|
|
||
| Assert.Equal("http://test_source", sourceItem.GetValueAsPath()); | ||
| Assert.Equal("https://test_source", sourceItem.GetValueAsPath()); |
There was a problem hiding this comment.
Is this test fix correct? I think -Verbosity Quiet shows errors and warnings, right?
There was a problem hiding this comment.
My understanding - this isn't testing output, but it's testing that a config file contains a particular URL. I'm actually not sure this assertion belongs here. The test is kind of overloaded.
There was a problem hiding this comment.
I think -Verbosity Quiet shows errors and warnings, right?
Yup that is my understanding too.
There was a problem hiding this comment.
I guess this change is required for assert at line#605 to pass.
| } | ||
|
|
||
| [PlatformTheory(Platform.Windows)] | ||
| [InlineData("http://source.test", true)] |
| if (httpPackageSources != null) | ||
| { | ||
| getLogger().LogWarning( | ||
| string.Format(CultureInfo.CurrentCulture, |
There was a problem hiding this comment.
I think there are 2 different scenarios possible here. A single HTTP source or multiple HTTP sources. The following implementation has different messages for each case. Can we reuse the same functionality here?
| { | ||
| httpPackageSources = new(); | ||
| } | ||
| httpPackageSources.Add(source); |
There was a problem hiding this comment.
By reading at code, it looks there is single source. If only single source is expected, then why bother creating new httpPackageSources list? it's unnecessary allocation.
Probably just do same thing you did in src/NuGet.Core/NuGet.Commands/SourcesCommands/SourceRunners.cs file.
There was a problem hiding this comment.
This is the list command so there are multiple sources, here I'm iterating through all the sources and storing the HTTP sources in a new list so I can print them later
| "test_source", | ||
| "-Source", | ||
| "http://test_source", | ||
| "https://test_source", |
There was a problem hiding this comment.
I guess this change is required for assert at line#605 to pass.
4e07795 to
580acbc
Compare
Bug
Fixes: https://github.com/NuGet/Client.Engineering/issues/1622
Regression? Last working version:
Description
Added a warn when using HTTP sources in dotnet and nuget commands.
PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation