提交 d9d88736 编写于 作者: C CyrusNajmabadi

Simplify API for tests to create options.

上级 00116264
......@@ -170,8 +170,8 @@ void baz()
";
await TestAsync(text, expected,
options: OptionsSet(
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedProperties, true, NotificationOption.None),
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, false, NotificationOption.None)));
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedProperties, true, NotificationOption.None),
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, false, NotificationOption.None)));
}
[Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField)]
......
......@@ -24,9 +24,10 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa
// specify all options explicitly to override defaults.
private IDictionary<OptionKey, object> ImplicitTypingEverywhere() =>
OptionSet(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithInfo);
OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithInfo));
internal IDictionary<OptionKey, object> OptionSet(OptionKey option, object value)
{
......
......@@ -28,10 +28,10 @@ public class GenerateVariableTests : AbstractCSharpDiagnosticProviderBasedUserDi
private readonly CodeStyleOption<bool> onWithInfo = new CodeStyleOption<bool>(true, NotificationOption.Suggestion);
// specify all options explicitly to override defaults.
private IDictionary<OptionKey, object> ImplicitTypingEverywhere() =>
OptionSet(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithInfo);
private IDictionary<OptionKey, object> ImplicitTypingEverywhere() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithInfo));
internal IDictionary<OptionKey, object> OptionSet(OptionKey option, object value)
{
......
......@@ -1257,8 +1257,8 @@ public override int M
}
}
}", options: OptionsSet(
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedProperties, true, NotificationOption.None),
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, false, NotificationOption.None)));
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedProperties, true, NotificationOption.None),
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, false, NotificationOption.None)));
}
[WorkItem(581500, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/581500")]
......@@ -1296,8 +1296,8 @@ public override int M
}
}
}", options: OptionsSet(
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedProperties, true, NotificationOption.None),
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, false, NotificationOption.None)));
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedProperties, true, NotificationOption.None),
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, false, NotificationOption.None)));
}
[WorkItem(581500, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/581500")]
......@@ -1356,8 +1356,8 @@ class T : A
}
}
}", options: OptionsSet(
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedIndexers, true, NotificationOption.None),
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, false, NotificationOption.None)));
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedIndexers, true, NotificationOption.None),
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, false, NotificationOption.None)));
}
[WorkItem(581500, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/581500")]
......@@ -1395,8 +1395,8 @@ class T : A
}
}
}", options: OptionsSet(
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedIndexers, true, NotificationOption.None),
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, false, NotificationOption.None)));
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedIndexers, true, NotificationOption.None),
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, false, NotificationOption.None)));
}
[WorkItem(581500, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/581500")]
......@@ -1426,8 +1426,8 @@ public override int M
get => throw new NotImplementedException();
}
}", options: OptionsSet(
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedProperties, false, NotificationOption.None),
Tuple.Create((IOption)CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, true, NotificationOption.None)));
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedProperties, false, NotificationOption.None),
SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, true, NotificationOption.None)));
}
[WorkItem(581500, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/581500")]
......
......@@ -24,21 +24,21 @@ public partial class PreferFrameworkTypeTests : AbstractCSharpDiagnosticProvider
private readonly CodeStyleOption<bool> onWithInfo = new CodeStyleOption<bool>(true, NotificationOption.Suggestion);
private readonly CodeStyleOption<bool> offWithInfo = new CodeStyleOption<bool>(false, NotificationOption.Suggestion);
private IDictionary<OptionKey, object> NoFrameworkType =>
Option(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, true, NotificationOption.Suggestion)
.With(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, onWithInfo, GetLanguage());
private IDictionary<OptionKey, object> NoFrameworkType => OptionsSet(
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, true, NotificationOption.Suggestion),
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, onWithInfo, GetLanguage()));
private IDictionary<OptionKey, object> FrameworkTypeEverywhere =>
Option(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, false, NotificationOption.Suggestion)
.With(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, offWithInfo, GetLanguage());
private IDictionary<OptionKey, object> FrameworkTypeEverywhere => OptionsSet(
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, false, NotificationOption.Suggestion),
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, offWithInfo, GetLanguage()));
private IDictionary<OptionKey, object> FrameworkTypeInDeclaration =>
Option(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, false, NotificationOption.Suggestion)
.With(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, onWithInfo, GetLanguage());
private IDictionary<OptionKey, object> FrameworkTypeInDeclaration => OptionsSet(
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, false, NotificationOption.Suggestion),
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, onWithInfo, GetLanguage()));
private IDictionary<OptionKey, object> FrameworkTypeInMemberAccess =>
Option(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, true, NotificationOption.Suggestion)
.With(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, offWithInfo, GetLanguage());
private IDictionary<OptionKey, object> FrameworkTypeInMemberAccess => OptionsSet(
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, true, NotificationOption.Suggestion),
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, offWithInfo, GetLanguage()));
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseFrameworkType)]
public async Task NotWhenOptionsAreNotSet()
......
......@@ -3770,17 +3770,17 @@ private async Task TestWithPredefinedTypeOptionsAsync(string code, string expect
await TestAsync(code, expected, index, options: PreferIntrinsicTypeEverywhere);
}
private IDictionary<OptionKey, object> PreferIntrinsicTypeEverywhere =>
Option(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, true, NotificationOption.Error)
.With(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, this.onWithError, GetLanguage());
private IDictionary<OptionKey, object> PreferIntrinsicTypeEverywhere => OptionsSet(
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, true, NotificationOption.Error),
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, this.onWithError, GetLanguage()));
private IDictionary<OptionKey, object> PreferIntrinsicTypeInDeclaration =>
Option(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, true, NotificationOption.Error)
.With(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, this.offWithNone, GetLanguage());
private IDictionary<OptionKey, object> PreferIntrinsicTypeInDeclaration => OptionsSet(
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, true, NotificationOption.Error),
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, this.offWithNone, GetLanguage()));
private IDictionary<OptionKey, object> PreferIntrinsicTypeInMemberAccess =>
Option(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, true, NotificationOption.Error)
.With(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, this.offWithNone, GetLanguage());
private IDictionary<OptionKey, object> PreferIntrinsicTypeInMemberAccess => OptionsSet(
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, true, NotificationOption.Error),
SingleOption(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, this.offWithNone, GetLanguage()));
private readonly CodeStyleOption<bool> onWithNone = new CodeStyleOption<bool>(true, NotificationOption.None);
private readonly CodeStyleOption<bool> offWithNone = new CodeStyleOption<bool>(false, NotificationOption.None);
......
......@@ -932,8 +932,9 @@ void N()
</Workspace>";
var options = OptionsSet(
Tuple.Create((IOption)CodeStyleOptions.QualifyPropertyAccess, false, NotificationOption.Suggestion),
Tuple.Create((IOption)CodeStyleOptions.QualifyFieldAccess, true, NotificationOption.Suggestion));
SingleOption(CodeStyleOptions.QualifyPropertyAccess, false, NotificationOption.Suggestion),
SingleOption(CodeStyleOptions.QualifyFieldAccess, true, NotificationOption.Suggestion));
await TestAsync(
initialMarkup: input,
expectedMarkup: expected,
......
......@@ -34,30 +34,30 @@ public partial class UseExplicitTypeTests : AbstractCSharpDiagnosticProviderBase
private readonly CodeStyleOption<bool> offWithError = new CodeStyleOption<bool>(false, NotificationOption.Error);
// specify all options explicitly to override defaults.
private IDictionary<OptionKey, object> ExplicitTypeEverywhere() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, offWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo);
private IDictionary<OptionKey, object> ExplicitTypeExceptWhereApparent() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo);
private IDictionary<OptionKey, object> ExplicitTypeForBuiltInTypesOnly() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo);
private IDictionary<OptionKey, object> ExplicitTypeEnforcements() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithWarning)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, offWithError)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo);
private IDictionary<OptionKey, object> ExplicitTypeNoneEnforcement() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithNone)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, offWithNone)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithNone);
private IDictionary<OptionKey, object> ExplicitTypeEverywhere() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, offWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo));
private IDictionary<OptionKey, object> ExplicitTypeExceptWhereApparent() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo));
private IDictionary<OptionKey, object> ExplicitTypeForBuiltInTypesOnly() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo));
private IDictionary<OptionKey, object> ExplicitTypeEnforcements() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithWarning),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, offWithError),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo));
private IDictionary<OptionKey, object> ExplicitTypeNoneEnforcement() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithNone),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, offWithNone),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithNone));
private IDictionary<OptionKey, object> Options(OptionKey option, object value)
{
......
......@@ -34,35 +34,35 @@ public partial class UseImplicitTypeTests : AbstractCSharpDiagnosticProviderBase
private static readonly CodeStyleOption<bool> offWithError = new CodeStyleOption<bool>(false, NotificationOption.Error);
// specify all options explicitly to override defaults.
public static IDictionary<OptionKey, object> ImplicitTypeEverywhere() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithInfo);
private IDictionary<OptionKey, object> ImplicitTypeWhereApparent() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo);
private IDictionary<OptionKey, object> ImplicitTypeWhereApparentAndForIntrinsics() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithInfo);
public static IDictionary<OptionKey, object> ImplicitTypeButKeepIntrinsics() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo);
private IDictionary<OptionKey, object> ImplicitTypeEnforcements() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithWarning)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithError)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithInfo);
private IDictionary<OptionKey, object> ImplicitTypeNoneEnforcement() =>
Options(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithNone)
.With(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithNone)
.With(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithNone);
public IDictionary<OptionKey, object> ImplicitTypeEverywhere() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithInfo));
private IDictionary<OptionKey, object> ImplicitTypeWhereApparent() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo));
private IDictionary<OptionKey, object> ImplicitTypeWhereApparentAndForIntrinsics() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, offWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithInfo));
public IDictionary<OptionKey, object> ImplicitTypeButKeepIntrinsics() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, offWithInfo),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithInfo));
private IDictionary<OptionKey, object> ImplicitTypeEnforcements() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithWarning),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithError),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithInfo));
private IDictionary<OptionKey, object> ImplicitTypeNoneEnforcement() => OptionsSet(
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, onWithNone),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, onWithNone),
SingleOption(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, onWithNone));
private static IDictionary<OptionKey, object> Options(OptionKey option, object value)
{
......
......@@ -209,7 +209,7 @@ void M(string v)
{
}
}
}", options: UseImplicitTypeTests.ImplicitTypeEverywhere());
}", options: new UseImplicitTypeTests().ImplicitTypeEverywhere());
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineDeclaration)]
......@@ -234,7 +234,7 @@ void M(string v)
{
}
}
}", options: UseImplicitTypeTests.ImplicitTypeButKeepIntrinsics());
}", options: new UseImplicitTypeTests().ImplicitTypeButKeepIntrinsics());
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineDeclaration)]
......@@ -568,7 +568,7 @@ void M2(out int i)
void M2(out string s)
{
}
}", options: UseImplicitTypeTests.ImplicitTypeEverywhere());
}", options: new UseImplicitTypeTests().ImplicitTypeEverywhere());
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineDeclaration)]
......@@ -609,7 +609,7 @@ void M2(out int i)
void M2(out string s)
{
}
}", options: UseImplicitTypeTests.ImplicitTypeEverywhere());
}", options: new UseImplicitTypeTests().ImplicitTypeEverywhere());
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineDeclaration)]
......@@ -642,7 +642,7 @@ void M()
void M2<T>(out T i)
{
}
}", options: UseImplicitTypeTests.ImplicitTypeEverywhere());
}", options: new UseImplicitTypeTests().ImplicitTypeEverywhere());
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineDeclaration)]
......
......@@ -534,25 +534,68 @@ protected static IList<CodeAction> FlattenActions(IEnumerable<CodeAction> codeAc
: new[] { a }).ToList();
}
protected IDictionary<OptionKey, object> Option(IOption option, CodeStyleOption<bool> notification)
protected (OptionKey, object) SingleOption(Option<CodeStyleOption<bool>> option, bool enabled, NotificationOption notification)
=> throw new Exception();
protected (OptionKey, object) SingleOption(Option<CodeStyleOption<bool>> option, CodeStyleOption<bool> codeStyle)
=> throw new Exception();
protected (OptionKey, object) SingleOption(PerLanguageOption<CodeStyleOption<bool>> option, bool enabled, NotificationOption notification)
=> throw new Exception();
protected (OptionKey, object) SingleOption(PerLanguageOption<CodeStyleOption<bool>> option, CodeStyleOption<bool> codeStyle)
=> throw new Exception();
protected (OptionKey, object) SingleOption(PerLanguageOption<CodeStyleOption<bool>> option, CodeStyleOption<bool> codeStyle, string language)
=> throw new Exception();
protected IDictionary<OptionKey, object> Option(Option<CodeStyleOption<bool>> option, bool enabled, NotificationOption notification)
=> OptionsSet(SingleOption(option, enabled, notification));
protected IDictionary<OptionKey, object> Option(Option<CodeStyleOption<bool>> option, CodeStyleOption<bool> codeStyle)
=> OptionsSet(SingleOption(option, codeStyle));
protected IDictionary<OptionKey, object> Option(PerLanguageOption<CodeStyleOption<bool>> option, bool enabled, NotificationOption notification)
=> OptionsSet(SingleOption(option, enabled, notification));
protected IDictionary<OptionKey, object> Option(PerLanguageOption<CodeStyleOption<bool>> option, CodeStyleOption<bool> codeStyle)
=> OptionsSet(SingleOption(option, codeStyle));
protected IDictionary<OptionKey, object> OptionsSet(
params (OptionKey key, object value)[] options)
{
var result = new Dictionary<OptionKey, object>();
foreach (var option in options)
{
result.Add(option.key, option.value);
}
return result;
}
#if false
protected IDictionary<OptionKey, object> SingleOption(IOption option, CodeStyleOption<bool> notification)
=> Option(option, notification.Value, notification.Notification);
protected IDictionary<OptionKey, object> Option(IOption option, bool value, NotificationOption notification)
=> OptionsSet(Tuple.Create(option, value, notification));
protected IDictionary<OptionKey, object> SingleOption(IOption option, bool value, NotificationOption notification)
=> Options((option, value, notification));
protected IDictionary<OptionKey, object> Options(params (IOption option, bool enabled, NotificationOption notification)[] optionsToSet)
=> Options(optionsToSet.Select(vt => (
optionKey: new OptionKey(vt.option, vt.option.IsPerLanguage ? GetLanguage() : null),
value: (object)new CodeStyleOption<bool>(vt.enabled, vt.notification))).ToArray());
protected IDictionary<OptionKey, object> OptionsSet(params Tuple<IOption, bool, NotificationOption>[] optionsToSet)
protected IDictionary<OptionKey, object> Options(
params (OptionKey key, object value)[] optionsToSet)
{
var options = new Dictionary<OptionKey, object>();
foreach (var triple in optionsToSet)
foreach (var option in optionsToSet)
{
var option = triple.Item1;
var value = triple.Item2;
var notification = triple.Item3;
var optionKey = new OptionKey(option, option.IsPerLanguage ? GetLanguage() : null);
options.Add(optionKey, new CodeStyleOption<bool>(value, notification));
options.Add(option.key, option.value);
}
return options;
}
#endif
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ namespace Microsoft.CodeAnalysis.Editor.UnitTests
{
internal static class OptionExtensions
{
#if false
internal static IDictionary<OptionKey, object> With(this IDictionary<OptionKey, object> options, OptionKey option, object value)
{
options.Add(option, value);
......@@ -19,5 +20,6 @@ internal static class OptionExtensions
options.Add(new OptionKey(option, language), value);
return options;
}
#endif
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册