提交 edb8cf39 编写于 作者: C CyrusNajmabadi

Properly generate type syntax for tuples with less than arity-2.

上级 5b5eb995
......@@ -141,6 +141,35 @@ class Class : IInterface
}");
}
[WorkItem(16793, "https://github.com/dotnet/roslyn/issues/16793")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
public async Task TestMethodWithValueTupleArity1()
{
await TestWithAllCodeStyleOptionsOffAsync(
@"
using System;
interface I
{
ValueTuple<object> F();
}
class C : [|I|]
{
}",
@"
using System;
interface I
{
ValueTuple<object> F();
}
class C : I
{
public ValueTuple<object> F()
{
throw new NotImplementedException();
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)]
public async Task TestExpressionBodiedMethod1()
{
......
......@@ -100,6 +100,11 @@ public TypeSyntax CreateSimpleTypeSyntax(INamedTypeSymbol symbol)
}
}
if (symbol.IsTupleType && symbol.TupleUnderlyingType != null && !symbol.Equals(symbol.TupleUnderlyingType))
{
return CreateSimpleTypeSyntax(symbol.TupleUnderlyingType);
}
if (symbol.Name == string.Empty || symbol.IsAnonymousType)
{
return CreateSystemObject();
......@@ -145,7 +150,7 @@ private TypeSyntax TryCreateSpecializedNamedTypeSyntax(INamedTypeSymbol symbol)
return SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.VoidKeyword));
}
if (symbol.IsTupleType)
if (symbol.IsTupleType && symbol.TupleElements.Length >= 2)
{
return CreateTupleTypeSyntax(symbol);
}
......
......@@ -102,7 +102,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
Return SyntaxFactory.QualifiedName(SyntaxFactory.IdentifierName("System"), SyntaxFactory.IdentifierName("DateTime"))
End Select
If symbol.IsTupleType Then
If symbol.IsTupleType AndAlso symbol.TupleElements.Length >= 2 Then
Return CreateTupleTypeSyntax(symbol)
End If
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册