From 3d943fe25fd480569bcc58683efd09bc272e2693 Mon Sep 17 00:00:00 2001 From: Martin Strecker Date: Wed, 27 Sep 2017 17:08:48 +0200 Subject: [PATCH] Type parameters always match the argument type. --- .../CSharpTest/AddParameter/AddParameterTests.cs | 8 +++++--- .../AddParameter/AbstractAddParameterCodeFixProvider.cs | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/AddParameter/AddParameterTests.cs b/src/EditorFeatures/CSharpTest/AddParameter/AddParameterTests.cs index 9ceb3f1c579..cec9b4d4e52 100644 --- a/src/EditorFeatures/CSharpTest/AddParameter/AddParameterTests.cs +++ b/src/EditorFeatures/CSharpTest/AddParameter/AddParameterTests.cs @@ -698,6 +698,7 @@ void M1() [WorkItem(21446, "https://github.com/dotnet/roslyn/issues/21446")] [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddParameter)] + [Trait("TODO", "Fix broken")] public async Task TestInvocationLambda1() { await TestInRegularAndScriptAsync( @@ -721,6 +722,7 @@ void M1() a(2); } }"); + //Should be Action a = (int v) => { }; } [WorkItem(21446, "https://github.com/dotnet/roslyn/issues/21446")] @@ -904,13 +906,13 @@ void M2() @" class C1 { - void M1(int v, T arg) { } + void M1(T arg, int v) { } void M2() { M1(1, 2); } }"); - //Should fix to either: void M1(T arg, int v) { } or void M1(T arg, T v) { } + //Should fix to: void M1(T arg, T v) { } } [WorkItem(21446, "https://github.com/dotnet/roslyn/issues/21446")] @@ -1129,7 +1131,7 @@ void M2() @" class C1 { - void M1(int v, T i) { } + void M1(T i, bool v) { } void M2() { M1(1, true); diff --git a/src/Features/Core/Portable/AddParameter/AbstractAddParameterCodeFixProvider.cs b/src/Features/Core/Portable/AddParameter/AbstractAddParameterCodeFixProvider.cs index bb5b020ad86..5bfd250995c 100644 --- a/src/Features/Core/Portable/AddParameter/AbstractAddParameterCodeFixProvider.cs +++ b/src/Features/Core/Portable/AddParameter/AbstractAddParameterCodeFixProvider.cs @@ -557,6 +557,11 @@ private int NonParamsParameterCount(IMethodSymbol method) return type.IsReferenceType || type.IsNullable(); } + if (type.Kind == SymbolKind.TypeParameter) + { + return true; + } + return false; } -- GitLab