提交 b9396297 编写于 作者: C CyrusNajmabadi

Simplify test harness.

上级 1ec0b0eb
......@@ -31,8 +31,7 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa
ParseOptions parseOptions = null,
CompilationOptions compilationOptions = null,
int index = 0, bool compareTokens = true,
IDictionary<OptionKey, object> options = null,
bool withScriptOption = false)
IDictionary<OptionKey, object> options = null)
{
options = options ?? new Dictionary<OptionKey, object>();
foreach (var kvp in AllOptionsOff)
......@@ -41,8 +40,7 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa
}
return TestAsync(initialMarkup, expectedMarkup,
parseOptions, compilationOptions, index, compareTokens, options,
withScriptOption: withScriptOption);
parseOptions, compilationOptions, index, compareTokens, options);
}
[Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField)]
......@@ -1397,7 +1395,8 @@ void M()
}
}
";
await TestAllOptionsOffAsync(text, expected, compareTokens: false, index: 1, parseOptions: TestOptions.Regular, withScriptOption: true);
await TestAllOptionsOffAsync(
text, expected, compareTokens: false, index: 1);
}
[Fact, Trait(Traits.Feature, Traits.Features.EncapsulateField), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)]
......@@ -1439,7 +1438,8 @@ void M()
}
}
";
await TestAllOptionsOffAsync(text, expected, compareTokens: false, index: 1, parseOptions: TestOptions.Regular, withScriptOption: true);
await TestAllOptionsOffAsync(
text, expected, compareTokens: false, index: 1);
}
}
}
......@@ -761,7 +761,7 @@ static void Main(string[] args)
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)]
public async Task Tuple()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C : [||]B
{
}
......@@ -784,16 +784,13 @@ class B
public B((int, string) x)
{
}
}",
index: 0,
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)]
public async Task TupleWithNames()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C : [||]B
{
}
......@@ -816,10 +813,7 @@ class B
public B((int a, string b) x)
{
}
}",
index: 0,
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
}
}
\ No newline at end of file
......@@ -3889,7 +3889,8 @@ public async Task ElementOfTuple()
var i = (1, V).ToString();
}";
await TestAsync(code, expected, index: 0, compareTokens: false, parseOptions: TestOptions.Regular, withScriptOption: true);
await TestInRegularAndScriptAsync(
code, expected, compareTokens: false);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsIntroduceVariable)]
......@@ -3908,7 +3909,7 @@ public async Task Tuple_IntroduceConstant()
var i = p.ToString();
}";
await TestAsync(code, expected, index: 0, compareTokens: false, parseOptions: TestOptions.Regular, withScriptOption: true);
await TestInRegularAndScriptAsync(code, expected, compareTokens: false);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsIntroduceVariable)]
......@@ -3927,7 +3928,7 @@ public async Task TupleWithNames_IntroduceConstant()
var i = p.ToString();
}";
await TestAsync(code, expected, index: 0, compareTokens: false, parseOptions: TestOptions.Regular, withScriptOption: true);
await TestInRegularAndScriptAsync(code, expected, compareTokens: false);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsIntroduceVariable)]
......@@ -3946,7 +3947,7 @@ public async Task Tuple_IntroduceConstantForAllOccurrences()
var i = p.ToString() + p.ToString();
}";
await TestAsync(code, expected, index: 1, compareTokens: false, parseOptions: TestOptions.Regular, withScriptOption: true);
await TestInRegularAndScriptAsync(code, expected, index: 1, compareTokens: false);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsIntroduceVariable)]
......@@ -3965,7 +3966,7 @@ public async Task TupleWithNames_IntroduceConstantForAllOccurrences()
var i = p.ToString() + p.ToString();
}";
await TestAsync(code, expected, index: 1, compareTokens: false, parseOptions: TestOptions.Regular, withScriptOption: true);
await TestInRegularAndScriptAsync(code, expected, index: 1, compareTokens: false);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsIntroduceVariable)]
......@@ -3984,7 +3985,7 @@ public async Task TupleWithDifferentNames_IntroduceConstantForAllOccurrences()
var i = p.ToString() + (c: 1, d: ""hello"").ToString();
}";
await TestAsync(code, expected, index: 1, compareTokens: false, parseOptions: TestOptions.Regular, withScriptOption: true);
await TestInRegularAndScriptAsync(code, expected, index: 1, compareTokens: false);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsIntroduceVariable)]
......@@ -4003,7 +4004,7 @@ public async Task TupleWithOneName_IntroduceConstantForAllOccurrences()
var i = p.ToString() + p.ToString();
}";
await TestAsync(code, expected, index: 1, compareTokens: false, parseOptions: TestOptions.Regular, withScriptOption: true);
await TestInRegularAndScriptAsync(code, expected, index: 1, compareTokens: false);
// no third action available
await TestActionCountAsync(code, 2, parseOptions: TestOptions.Regular);
......@@ -4014,7 +4015,7 @@ public async Task Tuple_IntroduceLocalForAllOccurrences()
{
// Cannot refactor tuple as local constant
await Assert.ThrowsAsync<Xunit.Sdk.InRangeException>(() =>
TestAsync(
TestInRegularAndScriptAsync(
@"class C
{
void Foo()
......@@ -4024,10 +4025,7 @@ void Foo()
}
}",
@"",
index: 3,
parseOptions: TestOptions.Regular,
withScriptOption: true)
);
index: 3));
}
[WorkItem(11777, "https://github.com/dotnet/roslyn/issues/11777")]
......
......@@ -590,7 +590,7 @@ static void Main(string[] args)
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveDeclarationNearReference)]
public async Task Tuple()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -610,16 +610,13 @@ void M()
Console.WriteLine(x);
}
}
}",
index: 0,
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveDeclarationNearReference)]
public async Task TupleWithNames()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -639,10 +636,7 @@ void M()
Console.WriteLine(x);
}
}
}",
index: 0,
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
}
}
}
\ No newline at end of file
......@@ -1215,9 +1215,7 @@ public async Task Tuple()
{
}
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)]
......@@ -1251,9 +1249,7 @@ class C
}
}
}" + TestResources.NetFX.ValueTuple.tuplelib_cs,
index: 1,
parseOptions: TestOptions.Regular,
withScriptOption: true);
index: 1);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)]
......@@ -1287,9 +1283,7 @@ class C
}
}
}" + TestResources.NetFX.ValueTuple.tuplelib_cs,
index: 1,
parseOptions: TestOptions.Regular,
withScriptOption: true);
index: 1);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)]
......@@ -1311,9 +1305,7 @@ void setFoo((int c, string d) i)
}
}",
@"",
index: 1,
parseOptions: TestOptions.Regular,
withScriptOption: true));
index: 1));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)]
......@@ -1691,14 +1683,13 @@ public async Task TestCodeStyle10()
private async Task TestWithAllCodeStyleOff(
string initialMarkup, string expectedMarkup,
ParseOptions parseOptions = null, int index = 0,
bool compareTokens = true, bool withScriptOption = false)
bool compareTokens = true)
{
await TestAsync(
initialMarkup, expectedMarkup, parseOptions,
index: index,
compareTokens: compareTokens,
options: AllCodeStyleOff,
withScriptOption: withScriptOption);
options: AllCodeStyleOff);
}
private IDictionary<OptionKey, object> AllCodeStyleOff =>
......
......@@ -1106,8 +1106,7 @@ static class E
public static void Deconstruct(this Program p, out int x, out int y) { }
}
}",
parseOptions: null,
withScriptOption: false);
parseOptions: null);
}
}
}
\ No newline at end of file
......@@ -1239,7 +1239,7 @@ class CAttribute
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsFullyQualify)]
public async Task TupleTest()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
([|IDictionary|], string) Method()
......@@ -1253,15 +1253,13 @@ public async Task TupleTest()
{
Foo();
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsFullyQualify)]
public async Task TupleWithOneName()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
([|IDictionary|] a, string) Method()
......@@ -1275,9 +1273,7 @@ public async Task TupleWithOneName()
{
Foo();
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
}
}
\ No newline at end of file
......@@ -2439,7 +2439,7 @@ public bool M(string s, int i, bool b)
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
public async Task Tuple()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2462,15 +2462,13 @@ void M()
{
new C((1, ""hello""), true);
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
public async Task TupleWithNames()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2491,15 +2489,13 @@ void M()
{
new C((a: 1, b: ""hello""));
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
public async Task TupleWithOneName()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2520,15 +2516,13 @@ void M()
{
new C((a: 1, ""hello""));
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
public async Task TupleAndExistingField()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2557,15 +2551,13 @@ public D((int, string) existing)
{
this.existing = existing;
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
public async Task TupleWithNamesAndExistingField()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2594,15 +2586,13 @@ public D((int a, string b) existing)
{
this.existing = existing;
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
public async Task TupleWithDifferentNamesAndExistingField()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2631,15 +2621,13 @@ public D((int a, string b) existing)
{
this.existing = existing;
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
public async Task TupleAndDelegatingConstructor()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2678,15 +2666,13 @@ class D : B
public D((int, string) x) : base(x)
{
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
public async Task TupleWithNamesAndDelegatingConstructor()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2725,15 +2711,13 @@ class D : B
public D((int a, string b) x) : base(x)
{
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
public async Task TupleWithDifferentNamesAndDelegatingConstructor()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2772,9 +2756,7 @@ class D : B
public D((int c, string d) x) : base(x)
{
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
......@@ -2863,7 +2845,7 @@ public D(int _)
[WorkItem(12147, "https://github.com/dotnet/roslyn/issues/12147")]
public async Task TestOutVariableDeclaration_ImplicitlyTyped()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2882,16 +2864,14 @@ void M()
{
new C(out var a);
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
[WorkItem(12147, "https://github.com/dotnet/roslyn/issues/12147")]
public async Task TestOutVariableDeclaration_ImplicitlyTyped_NamedArgument()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2910,16 +2890,14 @@ void M()
{
new C(b: out var a);
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
[WorkItem(12147, "https://github.com/dotnet/roslyn/issues/12147")]
public async Task TestOutVariableDeclaration_ExplicitlyTyped()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2938,16 +2916,14 @@ void M()
{
new C(out int a);
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
[WorkItem(12147, "https://github.com/dotnet/roslyn/issues/12147")]
public async Task TestOutVariableDeclaration_ExplicitlyTyped_NamedArgument()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void M()
......@@ -2966,9 +2942,7 @@ void M()
{
new C(b: out int a);
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
......@@ -2995,8 +2969,7 @@ void M()
new C(out var a);
}
}",
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6),
withScriptOption: true);
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
......@@ -3023,8 +2996,7 @@ void M()
new C(b: out var a);
}
}",
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6),
withScriptOption: true);
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
......@@ -3051,8 +3023,7 @@ void M()
new C(out int a);
}
}",
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6),
withScriptOption: true);
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
......@@ -3079,15 +3050,14 @@ void M()
new C(b: out int a);
}
}",
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6),
withScriptOption: true);
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
[WorkItem(13749, "https://github.com/dotnet/roslyn/issues/13749")]
public async Task Support_Readonly_Properties()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C {
public int Prop { get ; }
}
......@@ -3110,9 +3080,7 @@ class P {
var prop = 42 ;
var c = new C ( prop ) ;
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
}
}
\ No newline at end of file
......@@ -6869,7 +6869,7 @@ private T First<T>(List<T> list)
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
public async Task MethodWithTuple()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
void Method()
......@@ -6890,15 +6890,13 @@ void Method()
{
throw new NotImplementedException();
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
public async Task MethodWithTupleWithNames()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
void Method()
......@@ -6919,15 +6917,13 @@ void Method()
{
throw new NotImplementedException();
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
public async Task MethodWithTupleWithOneName()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
void Method()
......@@ -6948,9 +6944,7 @@ void Method()
{
throw new NotImplementedException();
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
......@@ -7090,8 +7084,7 @@ private void Undefined(out object c)
throw new NotImplementedException();
}
}",
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6),
withScriptOption: true);
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
......@@ -7119,8 +7112,7 @@ private void Undefined(out int c)
throw new NotImplementedException();
}
}",
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6),
withScriptOption: true);
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
......@@ -7148,8 +7140,7 @@ private void Undefined(out object a)
throw new NotImplementedException();
}
}",
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6),
withScriptOption: true);
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
......@@ -7177,8 +7168,7 @@ private void Undefined(out int a)
throw new NotImplementedException();
}
}",
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6),
withScriptOption: true);
parseOptions: TestOptions.Regular.WithLanguageVersion(CodeAnalysis.CSharp.LanguageVersion.CSharp6));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
......
......@@ -7029,7 +7029,7 @@ static C()
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)]
public async Task TupleRead()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
void Method((int, string) i)
......@@ -7045,15 +7045,13 @@ void Method((int, string) i)
{
Method(tuple);
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)]
public async Task TupleWithOneNameRead()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
void Method((int a, string) i)
......@@ -7069,15 +7067,13 @@ void Method((int a, string) i)
{
Method(tuple);
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)]
public async Task TupleWrite()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
void Method()
......@@ -7093,15 +7089,13 @@ void Method()
{
tuple = (1, ""hello"");
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)]
public async Task TupleWithOneNameWrite()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
void Method()
......@@ -7117,9 +7111,7 @@ void Method()
{
tuple = (a: 1, ""hello"");
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)]
......
......@@ -3858,7 +3858,7 @@ public enum Directions
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnnecessaryCast)]
public async Task Tuple()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void Main()
......@@ -3872,15 +3872,13 @@ void Main()
{
(int, string) tuple = (1, ""hello"");
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnnecessaryCast)]
public async Task TupleWithDifferentNames()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
void Main()
......@@ -3894,9 +3892,7 @@ void Main()
{
(int a, string) tuple = (1, f: ""hello"");
}
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[WorkItem(12572, "https://github.com/dotnet/roslyn/issues/12572")]
......
......@@ -819,7 +819,7 @@ int P
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseAutoProperty)]
public async Task Tuple_SingleGetterFromField()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
[|(int, string) i|];
......@@ -835,15 +835,13 @@ public async Task Tuple_SingleGetterFromField()
@"class Class
{
(int, string) P { get; }
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseAutoProperty)]
public async Task TupleWithNames_SingleGetterFromField()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
[|(int a, string b) i|];
......@@ -859,9 +857,7 @@ public async Task TupleWithNames_SingleGetterFromField()
@"class Class
{
(int a, string b) P { get; }
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseAutoProperty)]
......@@ -885,7 +881,7 @@ public async Task TupleWithDifferentNames_SingleGetterFromField()
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseAutoProperty)]
public async Task TupleWithOneName_SingleGetterFromField()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
[|(int a, string) i|];
......@@ -901,15 +897,13 @@ public async Task TupleWithOneName_SingleGetterFromField()
@"class Class
{
(int a, string) P { get; }
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseAutoProperty)]
public async Task Tuple_Initializer()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
[|(int, string) i = (1, ""hello"")|];
......@@ -925,15 +919,13 @@ public async Task Tuple_Initializer()
@"class Class
{
(int, string) P { get; } = (1, ""hello"");
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseAutoProperty)]
public async Task Tuple_GetterAndSetter()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Class
{
[|(int, string) i|];
......@@ -954,9 +946,7 @@ public async Task Tuple_GetterAndSetter()
@"class Class
{
(int, string) P { get; set; }
}",
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
}
}
\ No newline at end of file
......@@ -1126,7 +1126,7 @@ static void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsUseExplicitType)]
public async Task SuggestExplicitTypeOnLocalWithIntrinsicTypeTuple()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
static void M()
......@@ -1141,15 +1141,13 @@ static void M()
(int, string) s = (1, ""hello"");
}
}",
options: ExplicitTypeEverywhere(),
parseOptions: TestOptions.Regular,
withScriptOption: true);
options: ExplicitTypeEverywhere());
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsUseExplicitType)]
public async Task SuggestExplicitTypeOnLocalWithIntrinsicTypeTupleWithNames()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
static void M()
......@@ -1164,15 +1162,13 @@ static void M()
(int a, string b) s = (a: 1, b: ""hello"");
}
}",
options: ExplicitTypeEverywhere(),
parseOptions: TestOptions.Regular,
withScriptOption: true);
options: ExplicitTypeEverywhere());
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsUseExplicitType)]
public async Task SuggestExplicitTypeOnLocalWithIntrinsicTypeTupleWithOneName()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class C
{
static void M()
......@@ -1187,9 +1183,7 @@ static void M()
(int a, string) s = (a: 1, ""hello"");
}
}",
options: ExplicitTypeEverywhere(),
parseOptions: TestOptions.Regular,
withScriptOption: true);
options: ExplicitTypeEverywhere());
}
}
}
\ No newline at end of file
......@@ -1555,7 +1555,7 @@ public async Task SuggestVarOnLocalWithIntrinsicTypeTuple()
var before = @"class C { static void M() { [|(int a, string)|] s = (a: 1, ""hello""); } }";
var after = @"class C { static void M() { var s = (a: 1, ""hello""); } }";
await TestAsync(before, after, options: ImplicitTypeEverywhere(), parseOptions: TestOptions.Regular, withScriptOption: true);
await TestInRegularAndScriptAsync(before, after, options: ImplicitTypeEverywhere());
// We would rather this refactoring also worked. See https://github.com/dotnet/roslyn/issues/11094
await TestMissingInRegularAndScriptAsync(before, options: ImplicitTypeWhereApparent());
......@@ -1564,7 +1564,7 @@ public async Task SuggestVarOnLocalWithIntrinsicTypeTuple()
[WpfFact(Skip = "https://github.com/dotnet/roslyn/issues/11154"), Trait(Traits.Feature, Traits.Features.CodeActionsUseImplicitType)]
public async Task ValueTupleCreate()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"using System;
class C
......@@ -1583,9 +1583,7 @@ static void M()
var s = ValueTuple.Create(1, 1);
}
}" + trivial2uple,
options: ImplicitTypeWhereApparent(),
parseOptions: TestOptions.Regular,
withScriptOption: true);
options: ImplicitTypeWhereApparent());
}
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsUseImplicitType)]
......@@ -1642,7 +1640,7 @@ static void M()
[WorkItem(14052, "https://github.com/dotnet/roslyn/issues/14052")]
public async Task OfferOnForEachConversionIfItDoesNotChangesSemantics()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"using System;
using System.Collections.Generic;
......@@ -1699,9 +1697,7 @@ static void M()
}
}
}",
options: ImplicitTypeEverywhere(),
parseOptions: TestOptions.Regular,
withScriptOption: true);
options: ImplicitTypeEverywhere());
}
}
}
\ No newline at end of file
......@@ -210,7 +210,7 @@ public Program(bool b)
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)]
public async Task TestTuple()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Program
{
[|(int, string) i;
......@@ -231,14 +231,13 @@ public Program((int, string) i, (string, int) s)
this.i = i;
this.s = s;
}
}",
index: 0, parseOptions: TestOptions.Regular, withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)]
public async Task TestTupleWithNames()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Program
{
[|(int a, string b) i;
......@@ -259,8 +258,7 @@ public Program((int a, string b) i, (string c, int d) s)
this.i = i;
this.s = s;
}
}",
index: 0, parseOptions: TestOptions.Regular, withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)]
......@@ -282,7 +280,7 @@ public Program((int e, string f) i)
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)]
public async Task TestTupleOptional()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Program
{
[|(int, string) i;
......@@ -304,13 +302,13 @@ public Program((int, string) i, (string, int) s = default((string, int)))
this.s = s;
}
}",
index: 1, parseOptions: TestOptions.Regular, withScriptOption: true);
index: 1);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)]
public async Task TestTupleOptionalWithNames()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Program
{
[|(int a, string b) i;
......@@ -332,7 +330,7 @@ public Program((int a, string b) i, (string c, int d) s = default((string c, int
this.s = s;
}
}",
index: 1, parseOptions: TestOptions.Regular, withScriptOption: true);
index: 1);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)]
......@@ -354,7 +352,7 @@ public Program((int e, string f) i)
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)]
public async Task TestTupleWithNullable()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Program
{
[|(int?, bool?) i;
......@@ -375,14 +373,13 @@ public Program((int?, bool?) i, (byte?, long?) s)
this.i = i;
this.s = s;
}
}",
index: 0, parseOptions: TestOptions.Regular, withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddConstructorParametersFromMembers)]
public async Task TestTupleWithGenericss()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"class Program
{
[|(List<int>, List<bool>) i;
......@@ -403,8 +400,7 @@ public Program((List<int>, List<bool>) i, (List<byte>, List<long>) s)
this.i = i;
this.s = s;
}
}",
index: 0, parseOptions: TestOptions.Regular, withScriptOption: true);
}");
}
}
}
......@@ -529,7 +529,7 @@ static void Test()
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructorFromMembers)]
public async Task Tuple()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"using System.Collections.Generic;
class Z
......@@ -546,10 +546,7 @@ public Z((int, string) a)
{
this.a = a;
}
}",
index: 0,
parseOptions: TestOptions.Regular,
withScriptOption: true);
}");
}
[WorkItem(14219, "https://github.com/dotnet/roslyn/issues/14219")]
......
......@@ -520,7 +520,7 @@ public override bool Equals(object obj)
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateEqualsAndGetHashCode)]
public async Task Tuples_Equals()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"using System.Collections.Generic;
class C
......@@ -538,15 +538,13 @@ public override bool Equals(object obj)
var c = obj as C;
return c != null && EqualityComparer<(int, string)>.Default.Equals(a, c.a);
}
}",
index: 0,
parseOptions: TestOptions.Regular, withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateEqualsAndGetHashCode)]
public async Task TupleWithNames_Equals()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"using System.Collections.Generic;
class C
......@@ -564,15 +562,13 @@ public override bool Equals(object obj)
var c = obj as C;
return c != null && EqualityComparer<(int x, string y)>.Default.Equals(a, c.a);
}
}",
index: 0,
parseOptions: TestOptions.Regular, withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateEqualsAndGetHashCode)]
public async Task Tuple_HashCode()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"using System.Collections.Generic;
class Program
......@@ -590,14 +586,13 @@ public override int GetHashCode()
return EqualityComparer<(int, string)>.Default.GetHashCode(i);
}
}",
index: 1,
parseOptions: TestOptions.Regular, withScriptOption: true);
index: 1);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateEqualsAndGetHashCode)]
public async Task TupleWithNames_HashCode()
{
await TestAsync(
await TestInRegularAndScriptAsync(
@"using System.Collections.Generic;
class Program
......@@ -615,9 +610,7 @@ public override int GetHashCode()
return EqualityComparer<(int x, string y)>.Default.GetHashCode(i);
}
}",
index: 1,
parseOptions: TestOptions.Regular,
withScriptOption: true);
index: 1);
}
}
}
......@@ -58,31 +58,28 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
internal async Task TestWithAllCodeStyleOptionsOffAsync(
string initialMarkup, string expectedMarkup,
int index = 0, bool compareTokens = true,
ParseOptions parseOptions = null,
bool withScriptOption = false)
ParseOptions parseOptions = null)
{
await TestAsync(initialMarkup, expectedMarkup, parseOptions, null,
index, compareTokens, options: s_allOptionsOff, withScriptOption: withScriptOption);
index, compareTokens, options: s_allOptionsOff);
}
internal async Task TestWithAllCodeStyleOptionsOnAsync(
string initialMarkup, string expectedMarkup,
int index = 0, bool compareTokens = true,
ParseOptions parseOptions = null,
bool withScriptOption = false)
ParseOptions parseOptions = null)
{
await TestAsync(initialMarkup, expectedMarkup, parseOptions, null,
index, compareTokens, options: s_allOptionsOn, withScriptOption: withScriptOption);
index, compareTokens, options: s_allOptionsOn);
}
internal async Task TestWithAccessorCodeStyleOptionsOnAsync(
string initialMarkup, string expectedMarkup,
int index = 0, bool compareTokens = true,
ParseOptions parseOptions = null,
bool withScriptOption = false)
ParseOptions parseOptions = null)
{
await TestAsync(initialMarkup, expectedMarkup, parseOptions, null,
index, compareTokens, options: s_accessorOptionsOn, withScriptOption: withScriptOption);
index, compareTokens, options: s_accessorOptionsOn);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
......@@ -6520,8 +6517,7 @@ class Class : IInterface
{
throw new System.NotImplementedException();
}
}",
parseOptions: TestOptions.Regular, withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
......@@ -6550,8 +6546,7 @@ class Class : IInterface
{
throw new System.NotImplementedException();
}
}",
parseOptions: TestOptions.Regular, withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
......@@ -6580,8 +6575,7 @@ class Class : IInterface<(int, string), int>
{
throw new System.NotImplementedException();
}
}",
parseOptions: TestOptions.Regular, withScriptOption: true);
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
......@@ -6610,8 +6604,7 @@ class Class : IInterface<(int, string), int>
{
throw new System.NotImplementedException();
}
}",
parseOptions: TestOptions.Regular, withScriptOption: true);
}");
}
[WorkItem(15387, "https://github.com/dotnet/roslyn/issues/15387")]
......
......@@ -327,25 +327,7 @@ public abstract class AbstractCodeActionOrUserDiagnosticTest
IDictionary<OptionKey, object> options = null,
string fixAllActionEquivalenceKey = null,
object fixProviderData = null,
CodeActionPriority? priority = null,
bool withScriptOption = false)
{
await TestAsync(initialMarkup, expectedMarkup, parseOptions, compilationOptions, index, compareTokens, options, fixAllActionEquivalenceKey, fixProviderData, priority);
if (withScriptOption)
{
await TestAsync(initialMarkup, expectedMarkup, parseOptions.WithKind(SourceCodeKind.Script), compilationOptions, index, compareTokens, options, fixAllActionEquivalenceKey, fixProviderData, priority);
}
}
private async Task TestAsync(
string initialMarkup, string expectedMarkup,
ParseOptions parseOptions, CompilationOptions compilationOptions,
int index, bool compareTokens,
IDictionary<OptionKey, object> options,
string fixAllActionEquivalenceKey,
object fixProviderData,
CodeActionPriority? priority)
CodeActionPriority? priority = null)
{
MarkupTestFile.GetSpans(expectedMarkup.NormalizeLineEndings(), out var expected, out IDictionary<string, IList<TextSpan>> spanMap);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册