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

Removing a key using CLI now actually saves changes to nuget.config #4080

Merged
merged 2 commits into from
May 28, 2021

Conversation

donnie-msft
Copy link
Contributor

Bug

Fixes: NuGet/Home#8223

Regression? Last working version: No (not in this major version at least)

Description

It seems that removing a key has never actually updated the nuget.config file.

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Automated tests added - I added a test, which failed before making this code change, and now it passes.
    • OR
    • Test exception
    • OR
    • N/A
  • Documentation

    • Documentation PR or issue filled
    • OR
    • N/A - we already have docs that indicate this behavior, it's just that it didn't work as indicated.

@donnie-msft donnie-msft requested a review from a team as a code owner May 28, 2021 20:16
<config>
<add key=""" + keyName + @""" value=""Highest"" />
</config>
</configuration>";
Copy link
Contributor

@erdembayar erdembayar May 28, 2021

Choose a reason for hiding this comment

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

            var config = $@"
<configuration>
    <config>
        <add key=""{keyName}"" value=""Highest"" />
    </config>
</configuration>";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually agree that this is easier to read, but in recent PR reviews, I've learned it's worse performance. Since this is a test, perf isn't really critical here, and it's probably negligible anyway, but I don't see enough value to rerun CI since it's already green.

Copy link
Member

Choose a reason for hiding this comment

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

Unless the compiler has improvements I don't know about, interpolated strings (strings starting with $) are syntactic sugar for string.Format, which has much slower runtime performance than string.Concat (which operator +(string a, string b) is syntactic sugar for).

This is a test, so it's not a perf-critical hot-path. But, unless you find concatenated strings much less readable than interpolated strings, I think it's fine as-is.

Copy link
Contributor

@erdembayar erdembayar left a comment

Choose a reason for hiding this comment

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

Minor suggestion.

<config>
<add key=""" + keyName + @""" value=""Highest"" />
</config>
</configuration>";
Copy link
Member

Choose a reason for hiding this comment

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

Unless the compiler has improvements I don't know about, interpolated strings (strings starting with $) are syntactic sugar for string.Format, which has much slower runtime performance than string.Concat (which operator +(string a, string b) is syntactic sugar for).

This is a test, so it's not a perf-critical hot-path. But, unless you find concatenated strings much less readable than interpolated strings, I think it's fine as-is.

@donnie-msft donnie-msft merged commit 0fc58e1 into dev May 28, 2021
@donnie-msft donnie-msft deleted the dev-donnie-msft-removeConfigKeyCLI branch May 28, 2021 23:29
Copy link
Contributor

@dominoFire dominoFire left a comment

Choose a reason for hiding this comment

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

LGTM. I'm curious how it works with nested nuget.config files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants