From aac69302532e0759db25261d1b2714d9ab2204f0 Mon Sep 17 00:00:00 2001 From: Gen Lu Date: Mon, 16 Sep 2019 18:10:29 -0700 Subject: [PATCH] Add codefix tests --- ...ariablesAsArgumentsCodeFixProviderTests.cs | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/PassInCapturedVariablesAsArgumentsCodeFixProviderTests.cs b/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/PassInCapturedVariablesAsArgumentsCodeFixProviderTests.cs index 0c87c5d9463..ce1a6c04f76 100644 --- a/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/PassInCapturedVariablesAsArgumentsCodeFixProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/MakeLocalFunctionStatic/PassInCapturedVariablesAsArgumentsCodeFixProviderTests.cs @@ -342,6 +342,70 @@ static int AddLocal(int a = 0, int b = 0, int x = 0, string y = null) }" , parseOptions: CSharp8ParseOptions); } + + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] + public async Task TestWarningAnnotation() + { + await TestInRegularAndScriptAsync( +@"class C +{ + void N(int x) + { + Func del = AddLocal; + + static int AddLocal() + { + return [||]x + 1; + } + } +}", +@"class C +{ + void N(int x) + { + Func del = AddLocal; + + {|Warning:static int AddLocal(int x) + { + return x + 1; + }|} + } +}", +parseOptions: CSharp8ParseOptions); + } + + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)] + public async Task TestNonCamelCaseCapture() + { + await TestInRegularAndScriptAsync( +@"class C +{ + int N(int x) + { + int Static = 0; + return AddLocal(); + + static int AddLocal() + { + return [||]Static + 1; + } + } +}", +@"class C +{ + int N(int x) + { + int Static = 0; + return AddLocal(Static); + + static int AddLocal(int @static) + { + return @static + 1; + } + } +}", +parseOptions: CSharp8ParseOptions); + } } } -- GitLab