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

Visual Studio Editor Options bug fixes #5999

Merged
merged 3 commits into from
Dec 11, 2018
Merged

Conversation

majocha
Copy link
Contributor

@majocha majocha commented Dec 10, 2018

Settings changes now sync properly between two or more open Visual Studio instances. (Fixes #5997)
UI logic for saving and restoring options is more robust and follows what Roslyn does.
Fixes #5998
Some comments added.

edit:
Tested on another machine and the settings sync nicely both locally and between two PCs.

let storageKey (typ: Type) = typ.Namespace + "." + typ.Name

let storageKeyVersions (typ: Type) =
// "TextEditor" prefix seems to be required for settings changes to be synced between IDE instances
Copy link
Contributor

Choose a reason for hiding this comment

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

That's very good to know. Thank you for the comment on this.

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 should've probably added that it's a lucky guess from looking at Roslyn source 😄. I haven't found it documented anywhere in the open.

Copy link
Contributor

@TIHan TIHan left a comment

Choose a reason for hiding this comment

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

I know this is still WIP, but at this time I want to give my feedback, namely on the cloning and both Read and Get.

The comments added are great and very informative.


member __.Read() = read()
// make a deep copy so that PopulateObject does not alter the original
let copy = clone settings
Copy link
Contributor

@TIHan TIHan Dec 11, 2018

Choose a reason for hiding this comment

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

I feel like we should not have to do any deep cloning here. If the reason is because we are modifying existing immutable objects, we need to stop doing that altogether because that gives me goosebumps.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we can find a way to stop modifying immutable objects, we should never have to call JsonConvert.PopulateObject and get rid of the [<CLIMutable>] attribute on the options. I strongly suggest trying design something with that in mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I absolutely agree both of these smell bad. In my defence, at the time I was trying to get something up and running quickly, that would be easy to use so we could have some way to configure things, hoping that in the long run we could tap into the Roslyn infrastructure, but this is still internal, I think.

The proper thing to do here would bo to declare, store and retrieve each and every configurable value separately, the way Roslyn does, that would let us get rid of the PopulateObject stuff. Technically the CLIMutable is not required when someone is willing to write the boilerplate to bind everything to the UI.

@majocha majocha changed the title [WIP] Visual Studio Editor Options bug fixes Visual Studio Editor Options bug fixes Dec 11, 2018
@majocha
Copy link
Contributor Author

majocha commented Dec 11, 2018

@TIHan this PR is pretty minimal, bug fixes and to document the things as they are right now. I agree a more robust, fully immutable design would be nice to have at some point, but it's beyond the scope of this PR.

@@ -130,8 +130,8 @@ type EditorOptions
interface Microsoft.CodeAnalysis.Host.IWorkspaceService

interface IPersistSettings with
member __.Read() = store.Read()
member __.Write(settings) = store.Write(settings)
member __.LoadSettings() = store.LoadSettings()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is much better :)

@TIHan
Copy link
Contributor

TIHan commented Dec 11, 2018

It's not an immutable design honestly, in regards to EditorOptions. Data such as IntellisenseOptions is already designed as immutable data but can be modified anyway; that's the part that makes me feel icky.

I understand your view. I'm happy to take what you have since it resolves the bugs.

@TIHan TIHan merged commit 970bf1e into dotnet:master Dec 11, 2018
@majocha
Copy link
Contributor Author

majocha commented Dec 12, 2018

Thanks @TIHan, I think I have some fresh idea how to deal with the issue in a unobtrusive way.

@majocha majocha deleted the options-fix-sync branch December 12, 2018 14:01
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
* fix options ui logic and syncing between IDE instances

* add comments

* feedback
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.

3 participants