Simplify code for reading/writing settings#81515
Conversation
|
|
||
| internal Optional<object?> TryReadOptionValue(string storageKey, Type storageType, object? defaultValue) | ||
| { | ||
| if (storageType == typeof(bool)) |
There was a problem hiding this comment.
this reading is specific to the legacy settings codepath. It's how roslyn encoded specific values into the legacy settings store. it doesn't apply to the new unified settings system, and we don't want to actually share this code.
Note: youc an tell this was worthless becausein the PR i merged in, the unified settings path always converts the value to write into a string. So we would first do that, and then call into this helper to just call into Read<string>(); and do nothing else.
| private Task SetValueAsync(string storageKey, object? value) | ||
| => this.SettingsManager.SetValueAsync(storageKey, value, isMachineLocal: false); | ||
|
|
||
| internal override Optional<object?> TryReadOptionValue(OptionKey2 optionKey, string storageKey, Type storageType, object? defaultValue) |
There was a problem hiding this comment.
this is all just a move.
| Debug.Assert(typeof(T) == typeof(string)); | ||
| var retrieval = this.SettingsManager.GetReader().GetValue<T>( | ||
| storageKey, SettingReadOptions.NoRequirements); | ||
| if (storageType == typeof(int)) |
There was a problem hiding this comment.
the unified-settings codepath now gets simpler as well. it just handles ints (for tab-size/indent-size), and enums (for use-spaces, and indent-style).
If we move more things here, we can expand this out as appropriate.
JoeRobich
left a comment
There was a problem hiding this comment.
Looks like the unified settings persister will need to support booleans for indent_style and the tests will need to validate against the correct types instead of strings.
|
@JoeRobich right yuo are. i had tests for this, but they were in the wrong namespace, so i wasn't seeing they were failing locally :D |
c13519b to
664fdbf
Compare
|
/azp run roslyn-CI |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Realized in the shower that i made things too complicated. Simplifying greatly.