-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Expand persister deserialization to also take into account string and accessibility modifiers #27193
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
Conversation
|
Possible values found via: Then looking if any defines a roaming profile persister |
|
Can I get a buddy on this? |
|
@dpoeschl did code style options. @jasonmalinowski did option persister. |
|
@jinujoseph Delegated M2 approval will be needed. @Therzok If you want to give a crack at fixing this better (not special casing), I'd be for that. It's funny that we can serialize all of them in one way but not deserialize them. :-/ |
|
I can. So, 2 tasks to improve this PR:
|
|
I'd skip 1 for now (or do that independently) -- I could totally imagine right now we have some users with bad roamed profiles that we'd suddenly see a spike of non-fatal errors being reported. It might be a good thing to just have that change separate so if we have to roll that reporting back we can do so independently of your bug fix. |
|
Will wait for 2'nd task to be addressed. |
e334590 to
7def76d
Compare
|
Rebased and modified the code. So, there were a few choices at hand, each with its drawbacks, and this seems to be the simplest and best way to handle it, so a few comments below:
|
jasonmalinowski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, reflection. It's icky, but hey it's small at least.
|
@dpoeschl want to take a quick look at this as well? |
|
@jinujoseph Second task is done, so this would be ready for delegated M2 approval. |
|
Approved to merge for 15.8.PReview3 once tests are green |
This commit gets rid of having to manually track all the possible `T`s for `CodeStyleOption<T>`, by instantiating the type via activator. Sadly, it uses reflection, but there is no way to make the code function in a generic way that does not pollute the API.
|
test windows_debug_spanish_unit32_prtest |
|
test windows_release_vs-integration_prtest |
CodeStyleOption supports more than just bool and enums, so look into expanding this in the roaming profile persister.
It can be seen here:
roslyn/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOption.cs
Lines 151 to 152 in d6f483e
roslyn/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOption.cs
Lines 76 to 79 in d6f483e
roslyn/src/Workspaces/Core/Portable/CodeStyle/CodeStyleOption.cs
Lines 56 to 59 in d6f483e
This was discovered during porting option persisting to VSMac. We use a more flexible approach, but with reflection, due to the nature of how the serialization code is modeled:
https://github.com/mono/monodevelop/blob/bdc236c2faa86ecdd88d7f36c6294b028a92477e/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.RoslynServices.Options/RoslynPreferences.Properties.cs#L109-L129
Side note 2
It also seems you're not doing anything in case the types don't match, either report that or clear the stored setting:
Side note:
I think the current CodeStyleOption and NamingPreferences (de)serializers can be improved a bit, but for now, this patch works.
3 things at hand:
If the approach is kept to whitelist specific variants of CodeStyleOption, a test should be added to ensure all possible
Ts are handled (maybe just run through all the options that go in the persisterI think the approach is not scalable, since anyone can provide their own T (i.e. enum) for
CodeStyleOption<T>Only the persister works with FromXElement.
So, there could be some better way to model this. Can we make
FromXElementjust returnICodeStyleOptionand use reflection to get the required T and construct theCodeStyleOption<T>? That way, every other possible type for T (i.e. custom enum) can be handled, rather than whitelisting on a case-by-case basis.Ask Mode template not completed
Customer scenario
Some options might not get persisted even if surfaced int he UI.
Bugs this fixes
N/A
Workarounds, if any
None, really.
Risk
Someone can modify the user preference in the options UI and not see it persisted.
Performance impact
Don't think there's any
Is this a regression from a previous update?
Don't think so.
Root cause analysis
See side-note.
How was the bug found?
Porting over option persister in VSMac.
Test documentation updated?
None