提交 7eba8523 编写于 作者: J Jason Malinowski 提交者: GitHub

Merge pull request #19633 from jasonmalinowski/support-local-serialization-of-longs

Support serializing longs to/from the local registry
......@@ -13,7 +13,7 @@ internal static class AnalyzerABTestOptions
nameof(LastDateTimeUsedSuggestionAction), defaultValue: DateTime.MinValue.ToBinary(),
storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(LastDateTimeUsedSuggestionAction)));
public static readonly Option<uint> UsedSuggestedActionCount = new Option<uint>(nameof(AnalyzerABTestOptions), nameof(UsedSuggestedActionCount),
public static readonly Option<int> UsedSuggestedActionCount = new Option<int>(nameof(AnalyzerABTestOptions), nameof(UsedSuggestedActionCount),
defaultValue: 0, storageLocations: new LocalUserProfileStorageLocation(LocalRegistryPath + nameof(UsedSuggestedActionCount)));
public static readonly Option<bool> NeverShowAgain = new Option<bool>(nameof(AnalyzerABTestOptions), nameof(NeverShowAgain),
......
......@@ -14,8 +14,7 @@
namespace Microsoft.VisualStudio.LanguageServices.Implementation.Experimentation
{
// Disabling until https://github.com/dotnet/roslyn/issues/19629 is fixed.
// [Export(typeof(ISuggestedActionCallback))]
[Export(typeof(ISuggestedActionCallback))]
internal class AnalyzerVsixSuggestedActionCallback : ForegroundThreadAffinitizedObject, ISuggestedActionCallback
{
private const string AnalyzerEnabledFlight = @"LiveCA/LiveCAcf";
......@@ -52,7 +51,6 @@ public void OnSuggestedActionExecuted(SuggestedAction action)
// thread to get it
AssertIsForeground();
// If the user has previously clicked don't show again, then we bail out immediately
if (_workspace.Options.GetOption(AnalyzerABTestOptions.NeverShowAgain))
{
......
......@@ -75,6 +75,27 @@ bool IOptionPersister.TryFetch(OptionKey optionKey, out object value)
value = subKey.GetValue(key, defaultValue: (bool)optionKey.Option.DefaultValue ? 1 : 0).Equals(1);
return true;
}
else if (optionKey.Option.Type == typeof(long))
{
object untypedValue = subKey.GetValue(key, defaultValue: optionKey.Option.DefaultValue);
if (untypedValue is string stringValue)
{
// Due to a previous bug we were accidentally serializing longs as strings. Gracefully convert
// those back.
bool suceeded = long.TryParse(stringValue, out long longValue);
value = longValue;
return suceeded;
}
else if (untypedValue is long longValue)
{
value = longValue;
return true;
}
value = null;
return false;
}
else
{
// Otherwise we can just store normally
......@@ -108,6 +129,11 @@ bool IOptionPersister.TryPersist(OptionKey optionKey, object value)
subKey.SetValue(key, (bool)value ? 1 : 0, RegistryValueKind.DWord);
return true;
}
else if (optionKey.Option.Type == typeof(long))
{
subKey.SetValue(key, value, RegistryValueKind.QWord);
return true;
}
else
{
subKey.SetValue(key, value);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册