Skip to content

Commit

Permalink
Revert some unintentional changes that snuck into this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinCampbell committed Feb 15, 2018
1 parent 0c10f4b commit b9f774b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 674 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,276 +308,5 @@ bool TrySomething()
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedVariable)]
public async Task RemoveVariableAndComment()
{
await TestInRegularAndScriptAsync(
@"
class C
{
void M()
{
int [|unused|] = 0; // remove also comment
}
}
",
@"
class C
{
void M()
{
}
}
");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedVariable)]
public async Task RemoveVariableAndAssgnment()
{
await TestInRegularAndScriptAsync(
@"
class C
{
void M()
{
int [|b|] = 0;
b = 0;
}
}
",
@"
class C
{
void M()
{
}
}
");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedVariable)]
public async Task JointDeclarationRemoveFirst()
{
await TestInRegularAndScriptAsync(
@"
class C
{
int M()
{
int [|unused|] = 0, used = 0;
return used;
}
}
",
@"
class C
{
int M()
{
int used = 0;
return used;
}
}
");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedVariable)]
public async Task JointDeclarationRemoveSecond()
{
await TestInRegularAndScriptAsync(
@"
class C
{
int M()
{
int used = 0, [|unused|] = 0;
return used;
}
}
",
@"
class C
{
int M()
{
int used = 0;
return used;
}
}
");
}

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/23322"), Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedVariable)]
public async Task JointAssignmentRemoveFirst()
{
await TestInRegularAndScriptAsync(
@"
class C
{
int M()
{
int [|unused|] = 0;
int used = 0;
unused = used = 0;
return used;
}
}
",
@"
class C
{
int M()
{
int used = 0;
used = 0;
return used;
}
}
");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedVariable)]
public async Task JointAssignmentRemoveSecond()
{
await TestInRegularAndScriptAsync(
@"
class C
{
int M()
{
int used = 0;
int [|unused|] = 0;
used = unused = 0;
return used;
}
}
",
@"
class C
{
int M()
{
int used = 0;
used = 0;
return used;
}
}
");
}

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/22921"), Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedVariable)]
public async Task RemoveUnusedLambda()
{
await TestInRegularAndScriptAsync(
@"
class C
{
int M()
{
Func<int> [|unused|] = () =>
{
return 0;
};
return 1;
}
}
",
@"
class C
{
int M()
{
return 1;
}
}
");
}

[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
public async Task JointDeclarationRemoveBoth()
{
var input = @"
<Workspace>
<Project Language=""C#"" AssemblyName=""Assembly1"" CommonReferences=""true"">
<Document>
class C
{
int M()
{
int {|FixAllInDocument:a|} = 0, b = 0;
return 0;
}
}
</Document>
</Project>
</Workspace>
";

var expected = @"
<Workspace>
<Project Language=""C#"" AssemblyName=""Assembly1"" CommonReferences=""true"">
<Document>
class C
{
int M()
{
return 0;
}
}
</Document>
</Project>
</Workspace>
";

await TestInRegularAndScriptAsync(input, expected);
}

[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
public async Task JointAssignment()
{
var input = @"
<Workspace>
<Project Language=""C#"" AssemblyName=""Assembly1"" CommonReferences=""true"">
<Document>
class C
{
int M()
{
int a = 0;
int {|FixAllInDocument:b|} = 0;
a = b = 0;
return 0;
}
}
</Document>
</Project>
</Workspace>
";

var expected = @"
<Workspace>
<Project Language=""C#"" AssemblyName=""Assembly1"" CommonReferences=""true"">
<Document>
class C
{
int M()
{
int a = 0;
a = 0;
return 0;
}
}
</Document>
</Project>
</Workspace>
";

await TestInRegularAndScriptAsync(input, expected);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ protected async Task TestAddDocument(
{
var codeActions = await GetCodeActionsAsync(workspace, parameters);
await TestAddDocument(
workspace, expectedMarkup, index, expectedContainers,
workspace, expectedMarkup, index, expectedContainers,
expectedDocumentName, codeActions);
}
}
Expand Down Expand Up @@ -344,7 +344,7 @@ private async Task TestAsync(
TestParameters parameters)
{
MarkupTestFile.GetSpans(
expectedMarkup.NormalizeLineEndings(),
expectedMarkup.NormalizeLineEndings(),
out var expected, out IDictionary<string, ImmutableArray<TextSpan>> spanMap);

var conflictSpans = spanMap.GetOrAdd("Conflict", _ => ImmutableArray<TextSpan>.Empty);
Expand Down Expand Up @@ -489,7 +489,6 @@ internal static async Task<ImmutableArray<CodeActionOperation>> VerifyInputsAndG
int index, ImmutableArray<CodeAction> actions, CodeActionPriority? priority = null)
{
Assert.NotNull(actions);
Assert.NotEmpty(actions);
if (actions.Length == 1)
{
if (actions.Single() is TopLevelSuppressionCodeAction suppressionAction)
Expand Down
Loading

0 comments on commit b9f774b

Please sign in to comment.