From 60d89c91321a04cd9c3294ca2cba7a2c36f14b81 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Wed, 30 Sep 2020 10:07:53 -0700 Subject: [PATCH] IntroduceVariable on target-typed new (#48076) --- .../IntroduceVariableTests.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/CodeActions/IntroduceVariable/IntroduceVariableTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/IntroduceVariable/IntroduceVariableTests.cs index f822bd5a383..c1e0fc9f56d 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/IntroduceVariable/IntroduceVariableTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/IntroduceVariable/IntroduceVariableTests.cs @@ -7775,6 +7775,42 @@ public void M(string s) string {|Rename:v|} = $""""; s.Bar(v); } +}"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsIntroduceVariable)] + [WorkItem(44656, "https://github.com/dotnet/roslyn/issues/44656")] + public async Task ImplicitObjectCreation() + { + await TestInRegularAndScriptAsync(@" +class A +{ + public void Create(A a, B b) + { + } +} + +class B +{ + void M() + { + new A().Create(new A(), [|new(1)|]); + } +}", @" +class A +{ + public void Create(A a, B b) + { + } +} + +class B +{ + void M() + { + B {|Rename:b|} = new(1); + new A().Create(new A(), b); + } }"); } } -- GitLab