Skip to content

Options refactoring#55686

Merged
tmat merged 12 commits intodotnet:mainfrom
tmat:Experiments
Sep 3, 2021
Merged

Options refactoring#55686
tmat merged 12 commits intodotnet:mainfrom
tmat:Experiments

Conversation

@tmat
Copy link
Copy Markdown
Member

@tmat tmat commented Aug 18, 2021

Separate global client options from solution options - see #55728.

KeybindingResetDetector refactoring: Remove dependency on (VisualStudio)Workspace, remove IExperiment.

@ghost ghost added the Area-IDE label Aug 18, 2021
@tmat tmat marked this pull request as ready for review August 18, 2021 18:20
@tmat tmat requested a review from a team as a code owner August 18, 2021 18:20
@tmat
Copy link
Copy Markdown
Member Author

tmat commented Aug 18, 2021

@CyrusNajmabadi PTAL

@tmat tmat changed the title KeybindingResetDetector refactoring Options refactoring Aug 19, 2021
@jasonmalinowski jasonmalinowski self-requested a review August 27, 2021 01:17
Copy link
Copy Markdown
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

Overall I love getting services off from using the workspace just to grab global stuff, so nice. I wouldn't mind though if @sharwell at least took at look at the GlobalOptionService.cs changes; there's one or two comments that implied some ordering was important there, and I can't say I understood why that was there originally so I hesitate to say I can really sign off on it.

// We need to switch to UI thread to invoke TryApplyChanges.
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
_workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(options));
_optionService.SetGlobalOptions(s_statusOptions, ImmutableArray.Create<object>(currentStatus, needsReset));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really need to be setting both of these at once? I can't imagine there's a performance problem but the ease in which we could reorder something here and break it is worrisome to me.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't know if we really need to, but it seems reasonable since the code implements a state machine that transitions between state that's defined by both values.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure what you mean by reordering something and breaking it.

Comment on lines +48 to +51
/// Gets the current values of specified options.
/// All options are read atomically.
/// </summary>
ImmutableArray<object?> GetOptions(ImmutableArray<OptionKey> optionKeys);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really need this? The lack of typesafety here really worries me.

Copy link
Copy Markdown
Member Author

@tmat tmat Aug 31, 2021

Choose a reason for hiding this comment

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

This is not less type safe then GetOption<T> - using the latter API the caller passes arbitrary type as T and we blindly cast object to it. It's just hidden behind the call.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment on lines -375 to -376
// Ensure the option persisters are available before taking the global lock
var persisters = GetOptionPersisters();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was the ordering significant here? Did we have persisters updating the global state as a part of load?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Persisters are called by GetOption if the option hasn't been loaded yet. They are not updating anything anything just fetching value from the underlying storage. GetOption does update the dictionary of current values if it fetches value from a persister that wasn't fetch before. All that should be independent of persisting the new option value.

@tmat tmat force-pushed the Experiments branch 2 times, most recently from 3f29c3a to 5946b43 Compare September 1, 2021 18:35
@tmat tmat merged commit 9525fa5 into dotnet:main Sep 3, 2021
@ghost ghost added this to the Next milestone Sep 3, 2021
@tmat tmat deleted the Experiments branch September 3, 2021 22:40
@Cosifne Cosifne modified the milestones: Next, 17.0.P5 Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants