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

Onboard NuGet to Unified Settings and create General page #6229

Open
wants to merge 54 commits into
base: dev
Choose a base branch
from

Conversation

donnie-msft
Copy link
Contributor

@donnie-msft donnie-msft commented Jan 14, 2025

Bug

Fixes: NuGet/Home#14040

Description

General Options

The General Options are onboarded to the Unified Settings platform (USX) with the following major changes:

  1. Our repo has a new registration.json which declares the property string values and types.

  2. Our repo implements the IExternalSettingsProvider to react to user input from the Unified Settings general page.
    The provider wraps our existing NuGet.Configuration types so that the monikers we list in our registration.json can be passed to NuGet's IExternalSettingsProvider implementation by USX.

  3. A GeneralStub page was added which points to the USX General page when the customer has enabled USX. The reason for this is so that if a customer opens a legacy options NuGet page (eg, Configuration Files), they can still see "General" listed there and be able to open the USX General page directly.

image

Settings stored in NuGet.config

The link will open the Configuration Files settings page (which is currently a legacy VS Options dialog).

Details

image

Clear NuGet local resources

Pressing "Clear NuGet Local resources" results in a modal dialog so that customers have an opportunity to cancel the operation, as shown below.

Details

image

  • As with legacy VS options, once started, the command cannot be cancelled (though I've proposed an enhancement to this if we see customers are using the feature).

    • The default button is "No" for "Clear all NuGet resources?".
  • Pressing "Yes" will open a modal dialog showing:

    • A status message
    • An indeterminate progress indicator
    • A close button once the execution completes
  • The modal window is a WPF window bound to a ViewModel setup to Execute NuGet's clear all LocalsCommand, and indicate state for whether the command is in-progress, and provide a status message upon completion.

  • Once the window loads, it asks the VM to begin executing.

  • The command logs information to the Output Window in VS.

  • Once complete, the completion time is shown (legacy settings behavior) along with a completion status message (success or error text).

  • The close button is enabled.

  • If any error occurs, the exception will be shown in the dialog. Scrolling is supported for longer messages.

  • *Note that the aka.ms help URL shown is not directly clickable. This can be enhanced in a future iteration to be pulled out into its own Hyperlink.

  • Theming works properly in the modal dialog.

image

General Stub page

When a customer has opted-into Unified Settings then opens the legacy VS options for NuGet (eg, Package Sources), the General page will still appear.

Details Instead of providing content, the stub page provides a link to directly open the General USX page. Before closing the legacy options dialog, it will prompt to save any pending changes:

image

Psuedo-localization testing

Tested PLOC at minimum supported resolution of 1366x768 at 100% DPI scaling.

PLOC Screenshots

image
image
Note, I used a WPF runtime tool to add extra text that's shown here so I could be sure that a very long error message will scroll correctly.
image
image
image

Accessibility testing

The Clear Locals modal dialog shows all green in Accessibility Insights.
I will schedule a test pass for this change as well.

Accessibility Screenshots

image

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests - (Also see UI testing sections above). The settings provider just wraps existing NuGet.Configuration types, so relying on that test coverage for most of the NuGet settings logic.
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc. Document the General settings page in Unified Settings Home#14039

@donnie-msft donnie-msft requested a review from a team as a code owner January 14, 2025 17:27
Copy link

microsoft-github-policy-service bot commented Jan 14, 2025

This PR contains changes to XAML files. Verify that you've completed the following tasks:

@donnie-msft donnie-msft changed the title Dev donnie msft unified settings init three Onboard NuGet to Unified Settings and migrate General page Jan 14, 2025
@donnie-msft donnie-msft changed the title Onboard NuGet to Unified Settings and migrate General page Onboard NuGet to Unified Settings and create General page Jan 14, 2025
@jeffkl jeffkl requested review from zivkan and jeffkl January 14, 2025 21:14
default: break;
}

throw new ApplicationException("Unknown setting!");
Copy link
Member

Choose a reason for hiding this comment

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

just a thought, when the moniker is known, the code silently ignores when the value has the wrong type, so it doesn't feel entirely consistent to me to throw when the moniker is unknown.

Comment on lines +204 to +209
if (input is T value)
{
return Task.FromResult(ExternalSettingOperationResult.SuccessResult(value));
}

throw new ApplicationException("Error reading setting!");
Copy link
Member

Choose a reason for hiding this comment

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

Would it perhaps be better to cast, so that the exception message tells us what the expected and actual types are, rather than a static string that we'll only be able to understand via debugging (perfview trace attached to "record your steps" VS feedback won't have details of the error)

{
if (typeof(T) != typeof(string))
{
throw new ApplicationException("Error reading setting!");
Copy link
Member

Choose a reason for hiding this comment

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

Should the error say what the actual type is, so we have more information without needing to debug?

{
0 => (T)(object)MonikerPackagesConfig,
1 => (T)(object)MonikerPackageReference,
_ => throw new ApplicationException("Error reading setting!"),
Copy link
Member

Choose a reason for hiding this comment

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

Should we report the input value, so we have more information without needing to debug?

src/NuGet.Clients/NuGet.Tools/NuGetPackage.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@jeffkl jeffkl 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, thanks for including all of the screenshots. I'll review again after Andy's comments are resolved


<!-- Content -->
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<TextBlock Margin="0,12,0,12" TextWrapping="Wrap" Text="{Binding CommandCompleteText}" Visibility="{Binding IsCommandComplete, Converter={StaticResource BooleanToVisibilityConverter}}"/>

Choose a reason for hiding this comment

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

For accessibility, consider making this a LiveTextBlock (which is from the VS SDK) so it will "announce" changes to its text or visibility.

src/NuGet.Clients/NuGet.Tools/NuGetPackage.cs Outdated Show resolved Hide resolved
src/NuGet.Clients/NuGet.Tools/NuGetPackage.cs Outdated Show resolved Hide resolved
src/NuGet.Clients/NuGet.Tools/NuGetPackage.cs Outdated Show resolved Hide resolved
@donnie-msft donnie-msft force-pushed the dev-donnie-msft-unifiedSettingsInitThree branch from 781c5b5 to 79d5164 Compare January 16, 2025 00:09
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.

NuGet needs to onboard to Unified Settings and create General page
4 participants