提交 c7b48859 编写于 作者: C Cyrus Najmabadi

Simplify generics

上级 15848ffd
......@@ -4412,6 +4412,90 @@ class Base
");
}
[WorkItem(40649, "https://github.com/dotnet/roslyn/issues/40649")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)]
public async Task SimplifyAliasToGeneric1()
{
await TestInRegularAndScript1Async(
@"using System.Collections.Generic;
using MyList = System.Collections.Generic.List<int>;
class Base
{
public [|System.Collections.Generic.List<int>|] Goo;
}
",
@"using System.Collections.Generic;
using MyList = System.Collections.Generic.List<int>;
class Base
{
public MyList Goo;
}
");
}
[WorkItem(40649, "https://github.com/dotnet/roslyn/issues/40649")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)]
public async Task SimplifyAliasToGeneric2()
{
await TestInRegularAndScript1Async(
@"using System.Collections.Generic;
using MyList = System.Collections.Generic.List<int>;
class Base
{
public [|List<int>|] Goo;
}
",
@"using System.Collections.Generic;
using MyList = System.Collections.Generic.List<int>;
class Base
{
public MyList Goo;
}
");
}
[WorkItem(40649, "https://github.com/dotnet/roslyn/issues/40649")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)]
public async Task SimplifyAliasToGeneric3()
{
await TestInRegularAndScript1Async(
@"using System.Collections.Generic;
using MyList = System.Collections.Generic.List<int>;
class Base
{
public [|List<System.Int32>|] Goo;
}
",
@"using System.Collections.Generic;
using MyList = System.Collections.Generic.List<int>;
class Base
{
public MyList Goo;
}
");
}
[WorkItem(40649, "https://github.com/dotnet/roslyn/issues/40649")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)]
public async Task DoNotSimplifyIncorrectInstantiation()
{
await TestMissingAsync(
@"using System.Collections.Generic;
using MyList = System.Collections.Generic.List<int>;
class Base
{
public [|List<string>|] Goo;
}
");
}
[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)]
[InlineData("Boolean")]
[InlineData("Char")]
......
......@@ -1088,7 +1088,8 @@ public static bool IsAliasReplaceableExpression(this ExpressionSyntax expression
{
if (expression.Kind() == SyntaxKind.IdentifierName ||
expression.Kind() == SyntaxKind.QualifiedName ||
expression.Kind() == SyntaxKind.AliasQualifiedName)
expression.Kind() == SyntaxKind.AliasQualifiedName ||
expression.Kind() == SyntaxKind.GenericName)
{
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册