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

nuget sources: move implementation into NuGet.Commands.dll - refactor into SourcesArgs/SourcesRunner - move enums/strings #3112

Closed
wants to merge 11 commits into from

Conversation

rrelyea
Copy link
Contributor

@rrelyea rrelyea commented Nov 6, 2019

Bug

Fixes: NuGet/Home#4126 (part 1 or 2 to support for dotnet nuget sources)
Regression: No

Fix

Details: This set of work has reorganized the code from a monolithic SourcesCommand in NuGet.CommandLine to a SourcesCommand which creates a SourcesArgs and passes it to a SourcesRunner. Args/Runner are in NuGet.Commands.
This should maintain current functionality in "NuGet Sources" while enabling the dotnet nuget sources work to be built on top of the Args/Runner in NuGet.Commands in another PR soon.

Testing/Validation

Tests Added: I fixed a test that was skipped and have it run now, but didn't see need to add any new tests at this stage. Let me know if I am wrong there.

Reason for not adding tests: not changing any functionality, fairly good coverage already.
Validation: ran unit tests

@rrelyea rrelyea marked this pull request as ready for review November 7, 2019 20:09
@rrelyea rrelyea changed the title sources: refactor into SourcesArgs/Runner and move strings around nuget sources: move implementation into NuGet.Commands.dll - refactor into SourcesArgs/SourcesRunner - move enums/strings Nov 7, 2019
@@ -3047,474 +2990,6 @@ To prevent NuGet from downloading packages during build, open the Visual Studio
<data name="InstallCommandPackageAlreadyExists_cht" xml:space="preserve">
<value>已安裝封裝 "{0}"。</value>
</data>
<data name="SourcesCommandNoSources_csy" xml:space="preserve">
Copy link
Contributor Author

@rrelyea rrelyea Nov 7, 2019

Choose a reason for hiding this comment

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

Need to think through the localization impact of this string table change.
Moved the english strings into nuget.commands.dll, but deleted the localized strings in nuget.exe -- and was hoping standard localization would work. But NuGet.exe may be a different beast for loc.

Copy link
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

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

Some changes needed, mostly cleanup right now.

Copy link
Contributor

@donnie-msft donnie-msft left a comment

Choose a reason for hiding this comment

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

I like the improvements in the code, but want to make sure the throws becoming LogErrors is as expected. Assuming the spirit of this change is to show more validation errors to the user at once, rather than making them fix missing arguments 1 by 1.

@@ -5550,4 +5550,7 @@ nuget trusted-signers Remove -Name TrustedRepo</value>
<data name="PackageCommandDeterministic" xml:space="preserve">
<value>Specify if the command should create a deterministic package. Multiple invocations of the pack command will create the exact same package.</value>
</data>
<data name="SourcesActionInvalid" xml:space="preserve">
<value>nuget sources</value>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was likely a placeholder.

Copy link
Contributor

@donnie-msft donnie-msft left a comment

Choose a reason for hiding this comment

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

Looks like we're back to a throw-on-error model, so looks good.

Copy link
Member

@nkolev92 nkolev92 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 overall.

Some concern with the exception move. It feels like a leak.

{
if (string.IsNullOrEmpty(args.Name))
{
throw new CommandLineException(Strings.SourcesCommandNameRequired);
Copy link
Member

Choose a reason for hiding this comment

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

Why not use ArgumentException?

Copy link
Member

Choose a reason for hiding this comment

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

Discussed offline.

Whether we call this CommandLineException or something smarter like LocalizedException can be decided in the dotnet.exe side implementation of this.

Copy link
Member

Choose a reason for hiding this comment

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

fwiw, looking into our code...there's nothing that relies on this being a commandlineexception.

@rrelyea
Copy link
Contributor Author

rrelyea commented Feb 12, 2020

STarted another PR to covert this work. Got checked into 5.5 recently. Closing this PR.

@rrelyea rrelyea closed this Feb 12, 2020
@rrelyea rrelyea deleted the dev-rrelyea-sourcesStepByStep branch February 21, 2020 01:03
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.

add dotnet nuget <add|remove|update|disable|enable|list> source command
5 participants