提交 2aae0125 编写于 作者: G Gen Lu

Some cleanp up

上级 234e3048
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeRefactorings;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.MakeLocalFunctionStatic
{
public partial class MakeLocalFunctionStaticTests : AbstractCSharpCodeActionTest
public class MakeLocalFunctionStaticRefactoringTests : AbstractCSharpCodeActionTest
{
protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspace workspace, TestParameters parameters)
=> new MakeLocalFunctionStaticCodeRefactoringProvider();
......@@ -21,332 +19,398 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa
private static ParseOptions CSharp8ParseOptions = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8);
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestStandard()//TestAboveCSharp8()
public async Task ShouldNotTriggerForCSharp7()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
await TestMissingAsync(
@"class C
{
void M()
int N(int x)
{
}
return AddLocal();
int N(int x){
var y = AddLocal();
int [||]AddLocal()
{
return x + 1;
}
}
}", parameters: new TestParameters(parseOptions: CSharp72ParseOptions));
}
int[||] AddLocal()
{
return x += 1;
}
}
}",
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task ShouldNotTriggerIfNoCaptures()
{
await TestMissingAsync(
@"class C
{
int N(int x)
{
return AddLocal(x);
@"using System;
int [||]AddLocal(int x)
{
return x + 1;
}
}
}", parameters: new TestParameters(parseOptions: CSharp8ParseOptions));
}
class C
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task ShouldNotTriggerIfAlreadyStatic()
{
await TestMissingAsync(
@"class C
{
void M()
int N(int x)
{
}
return AddLocal(x);
int N(int x){
static int [||]AddLocal(int x)
{
return x + 1;
}
}
}", parameters: new TestParameters(parseOptions: CSharp8ParseOptions));
}
var y = AddLocal(x);
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task ShouldNotTriggerIfAlreadyStaticWithError()
{
await TestMissingAsync(
@"class C
{
int N(int x)
{
return AddLocal();
static int AddLocal(int x)
{
return x += 1;
}
}
}",
parseOptions: CSharp8ParseOptions);
static int [||]AddLocal()
{
return x + 1;
}
}
}", parameters: new TestParameters(parseOptions: CSharp8ParseOptions));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseSimpleUsingStatement)]
public async Task TestVariableAlreadyDefinedInStaticLocalFunction()
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task ShouldNotTriggerIfCapturesThisParameter()
{
await TestMissingAsync(
@"using System;
@"class C
{
int x;
int N()
{
return AddLocal();
int [||]AddLocal()
{
return x + 1;
}
}
}", parameters: new TestParameters(parseOptions: CSharp8ParseOptions));
}
class C
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task ShouldTriggerIfExplicitlyPassedInThisParameter()
{
await TestInRegularAndScriptAsync(
@"class C
{
void M()
int x;
int N()
{
}
int y;
return AddLocal(this);
int [||]AddLocal(C c)
{
return c.x + y;
}
}
}",
@"class C
{
int x;
int N(int x){
x = AddLocal();
int N()
{
int y;
return AddLocal(this, y);
int[||] AddLocal()
{
int x = 1;
return x += 1;
}
static int [||]AddLocal(C c, int y)
{
return c.x + y;
}
}
}", parameters: new TestParameters(parseOptions: CSharp72ParseOptions));
}
}", parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestMultipleVariables()
public async Task ShouldTriggerForCSharp8()
{
await TestInRegularAndScriptAsync(
@"using System;
@"class C
{
int N(int x)
{
return AddLocal();
class C
int [||]AddLocal()
{
return x + 1;
}
}
}",
@"class C
{
void M()
int N(int x)
{
}
return AddLocal(x);
int N(int x, int y){
static int AddLocal(int x)
{
return x + 1;
}
}
}",
parseOptions: CSharp8ParseOptions);
}
var z = AddLocal();
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestMultipleVariables()
{
await TestInRegularAndScriptAsync(
@"class C
{
int N(int x)
{
int y = 10;
return AddLocal();
int[||] AddLocal()
{
return x += y;
}
{
return x + y;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
var z = AddLocal(x, y);
int y = 10;
return AddLocal(x, y);
static int AddLocal(int x, int y)
{
return x += y;
}
}
{
return x + y;
}
}
}", parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestMultipleCalls()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x){
x = AddLocal();
int x2 = AddLocal();
return x + x2;
int y = 10;
return AddLocal() + AddLocal();
int[||] AddLocal()
{
return x += 1;
}
}
{
return x + y;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int y = 10;
return AddLocal(x, y) + AddLocal(x, y);
int N(int x){
x = AddLocal(x);
int x2 = AddLocal(x);
static int AddLocal(int x)
{
return x += 1;
}
}
static int AddLocal(int x, int y)
{
return x + y;
}
}
}", parseOptions: CSharp8ParseOptions);
}"
, parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestParametersAlreadyAddedToCallAndDeclaration()
{
await TestMissingInRegularAndScriptAsync(
@"using System;
class C
public async Task TestMultipleCallsWithExistingParameters()
{
void M()
{
}
int N(int x)
{
await TestInRegularAndScriptAsync(
@"class C
{
int N(int x)
{
int y = 10;
var m = AddLocal(1, 2);
return AddLocal(m, m);
x = AddLocal(x);
int[||] AddLocal(int a, int b)
{
return a + b + x + y;
}
}
}",
@"class C
{
int N(int x)
{
int y = 10;
var m = AddLocal(1, 2, x, y);
return AddLocal(m, m, x, y);
int[||] AddLocal(int x)
{
return x += 1;
}
}
static int AddLocal(int a, int b, int x, int y)
{
return a + b + x + y;
}
}", new TestParameters(
parseOptions: CSharp8ParseOptions));
}
}"
, parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestOneOfTwoVariablesDefinedinLocalStaticFunction()
public async Task TestRecursiveCall()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
x = AddLocal();
return x + y;
int y = 10;
var m = AddLocal(1, 2);
return AddLocal(m, m);
int[||] AddLocal()
{
int y = 5;
return x += y;
}
}
int[||] AddLocal(int a, int b)
{
return AddLocal(a, b) + x + y;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int y = 10;
var m = AddLocal(1, 2, x, y);
return AddLocal(m, m, x, y);
int N(int x, int y){
x = AddLocal(x,y);
return x + y;
static int AddLocal(int x, int y)
{
int y = 5;
return x += y;
}
}
static int AddLocal(int a, int b, int x, int y)
{
return AddLocal(a, b, x, y) + x + y;
}
}
}", parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestOneVariableAlreadyInParametersOfDeclarationAndCall()
public async Task TestCallInArgumentList()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
x = AddLocal(int x);
return x + y;
int y = 10;
return AddLocal(AddLocal(1, 2), AddLocal(3, 4));
int[||] AddLocal(int x)
{
return x += y;
}
}
int[||] AddLocal(int a, int b)
{
return AddLocal(a, b) + x + y;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
int y = 10;
return AddLocal(AddLocal(1, 2, x, y), AddLocal(3, 4, x, y), x, y);
x = AddLocal(x,y);
return x;
static int AddLocal(int x, int y)
{
return x += y;
}
}
static int AddLocal(int a, int b, int x, int y)
{
return AddLocal(a, b, x, y) + x + y;
}
}
}", parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestRecursiveCall()
public async Task TestCallsWithNamedArguments()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x){
int y = 10;
var m = AddLocal(1, b: 2);
return AddLocal(b: m, a: m);
x = AddLocal();
return x;
int[||] AddLocal()
{
x = AddLocal();
return x += 1;
}
}
int[||] AddLocal(int a, int b)
{
return a + b + x + y;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
int y = 10;
var m = AddLocal(1, b: 2, x: x, y: y);
return AddLocal(b: m, a: m, x: x, y: y);
static int AddLocal(int a, int b, int x, int y)
{
return a + b + x + y;
}
}
}"
, parseOptions: CSharp8ParseOptions);
}
int N(int x){
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestCallsWithDafaultValue()
{
await TestInRegularAndScriptAsync(
@"class C
{
int N(int x)
{
string y = "";
var m = AddLocal(1);
return AddLocal(b: m);
x = AddLocal(x);
int[||] AddLocal(int a = 0, int b = 0)
{
return a + b + x + y.Length;
}
}
}",
@"class C
{
int N(int x)
{
string y = "";
var m = AddLocal(1, x: x, y: y);
return AddLocal(b: m, x: x, y: y);
static int AddLocal(int x)
{
x = AddLocal(int x);
return x += 1;
}
}
static int AddLocal(int a = 0, int b = 0, int x = 0, string y = null)
{
return a + b + x + y.Length;
}
}
}", parseOptions: CSharp8ParseOptions);
}"
, parseOptions: CSharp8ParseOptions);
}
}
}
......
......@@ -3,422 +3,344 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.MakeLocalFunctionStatic
{
public partial class PassVariableExplicitlyInLocalStaticFunctionTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
public class PassInCapturedVariablesAsArgumentsCodeFixProviderTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (null, new PassVariableExplicitlyInLocalStaticFunctionCodeFixProvider());
=> (null, new PassInCapturedVariablesAsArgumentsCodeFixProvider());
private static ParseOptions CSharp72ParseOptions = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7_2);
private static ParseOptions CSharp8ParseOptions = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8);
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestStandard()//TestAboveCSharp8()
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseSimpleUsingStatement)]
public async Task TestMissingInCSharp7()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
await TestMissingAsync(
@"class C
{
void M()
int N(int x)
{
}
int N(int x){
var y = AddLocal();
return AddLocal();
static int AddLocal()
{
return [|x|] += 1;
}
}
}",
@"using System;
{
return [||]x + 1;
}
}
}", parameters: new TestParameters(parseOptions: CSharp72ParseOptions));
}
class C
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseSimpleUsingStatement)]
public async Task TestMissingIfNoDiagnostic()
{
await TestMissingAsync(
@"class C
{
void M()
int N(int x)
{
}
int N(int x){
return AddLocal();
var y = AddLocal(x);
static int AddLocal(int x)
{
return x += 1;
}
}
}",
parseOptions: CSharp8ParseOptions);
int AddLocal()
{
return [||]x + 1;
}
}
}", parameters: new TestParameters(parseOptions: CSharp8ParseOptions));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseSimpleUsingStatement)]
public async Task TestVariableAlreadyDefinedInStaticLocalFunction()
public async Task TestMissingIfCapturesThisParameter()
{
await TestMissingAsync(
@"using System;
class C
@"class C
{
void M()
{
}
int y = 0;
int N(int x){
x = AddLocal();
int N(int x)
{
return AddLocal();
static int AddLocal()
{
int x = 1;
return [|x|] += 1;
}
}
{
return [||]x + y;
}
}
}", parameters: new TestParameters(parseOptions: CSharp72ParseOptions));
}", parameters: new TestParameters(parseOptions: CSharp8ParseOptions));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestMultipleVariables1()
public async Task ShouldTriggerForCSharp8()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
var z = AddLocal();
return AddLocal();
static int AddLocal()
{
return [|x|] += y;
}
{
return [||]x + 1;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
return AddLocal(x);
var z = AddLocal(x, y);
static int AddLocal(int x, int y)
{
return x += y;
}
}
}
}", parseOptions: CSharp8ParseOptions);
static int AddLocal(int x)
{
return x + 1;
}
}
}",
parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestMultipleVariables2()
public async Task TestMultipleVariables()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
x = AddLocal();
return x + y;
int y = 10;
return AddLocal();
static int AddLocal()
{
return x += y[||];
}
}
{
return x + [||]y;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
x = AddLocal(x,y);
return x + y;
int y = 10;
return AddLocal(x, y);
static int AddLocal(int x, int y)
{
return x += y;
}
}
{
return x + y;
}
}
}", parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestMultipleCalls()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x){
x = AddLocal();
int x2 = AddLocal();
return x + x2;
int y = 10;
return AddLocal() + AddLocal();
static int AddLocal()
{
return x[||] += 1;
}
}
{
return [||]x + y;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int y = 10;
return AddLocal(x, y) + AddLocal(x, y);
int N(int x){
x = AddLocal(x);
int x2 = AddLocal(x);
static int AddLocal(int x)
{
return x += 1;
}
}
static int AddLocal(int x, int y)
{
return x + y;
}
}
}", parseOptions: CSharp8ParseOptions);
}"
, parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestParametersAlreadyAddedToCallAndDeclaration()
{
await TestMissingInRegularAndScriptAsync(
@"using System;
class C
public async Task TestMultipleCallsWithExistingParameters()
{
void M()
{
}
int N(int x)
{
await TestInRegularAndScriptAsync(
@"class C
{
int N(int x)
{
int y = 10;
var m = AddLocal(1, 2);
return AddLocal(m, m);
x = AddLocal(x);
static int AddLocal(int a, int b)
{
return a + b + [||]x + y;
}
}
}",
@"class C
{
int N(int x)
{
int y = 10;
var m = AddLocal(1, 2, x, y);
return AddLocal(m, m, x, y);
static int AddLocal(int x)
{
return x += 1;
}
}
static int AddLocal(int a, int b, int x, int y)
{
return a + b + x + y;
}
}", new TestParameters(
parseOptions: CSharp8ParseOptions));
}
}"
, parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestOneOfTwoVariablesDefinedinLocalStaticFunction()
public async Task TestRecursiveCall()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
x = AddLocal();
return x + y;
int y = 10;
var m = AddLocal(1, 2);
return AddLocal(m, m);
static int AddLocal()
{
int y = 5;
return x[||] += y;
}
}
static int AddLocal(int a, int b)
{
return AddLocal(a, b) + [||]x + y;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
x = AddLocal(x,y);
int y = 10;
var m = AddLocal(1, 2, x, y);
return AddLocal(m, m, x, y);
return x + y;
static int AddLocal(int x, int y)
{
int y = 5;
return x += y;
}
}
static int AddLocal(int a, int b, int x, int y)
{
return AddLocal(a, b, x, y) + x + y;
}
}
}", parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestOneVariableAlreadyInParametersOfDeclarationAndCall1()
public async Task TestCallInArgumentList()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
int y = 10;
return AddLocal(AddLocal(1, 2), AddLocal(3, 4));
x = AddLocal(int x);
return x + y;
static int AddLocal(int x)
{
return x += y[||];
}
}
static int AddLocal(int a, int b)
{
return AddLocal(a, b) + [||]x + y;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
x = AddLocal(x,y);
return x;
int y = 10;
return AddLocal(AddLocal(1, 2, x, y), AddLocal(3, 4, x, y), x, y);
static int AddLocal(int x, int y)
{
return x += y;
}
}
static int AddLocal(int a, int b, int x, int y)
{
return AddLocal(a, b, x, y) + x + y;
}
}
}", parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestOneVariableAlreadyInParametersOfDeclarationAndCall2()
public async Task TestCallsWithNamedArguments()
{
await TestMissingInRegularAndScriptAsync(
@"using System;
class C
await TestInRegularAndScriptAsync(
@"class C
{
void M()
int N(int x)
{
}
int N(int x, int y){
x = AddLocal(int x);
int y = 10;
var m = AddLocal(1, b: 2);
return AddLocal(b: m, a: m);
return x;
static int AddLocal(int a, int b)
{
return a + b + [||]x + y;
}
}
}",
@"class C
{
int N(int x)
{
int y = 10;
var m = AddLocal(1, b: 2, x: x, y: y);
return AddLocal(b: m, a: m, x: x, y: y);
static int AddLocal(int x)
{
return x[||] += y;
}
}
}", new TestParameters(
parseOptions: CSharp8ParseOptions));
static int AddLocal(int a, int b, int x, int y)
{
return a + b + x + y;
}
}
}"
, parseOptions: CSharp8ParseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeLocalFunctionStatic)]
public async Task TestRecursiveCall()
public async Task TestCallsWithDafaultValue()
{
await TestInRegularAndScriptAsync(
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x){
x = AddLocal();
return x;
string y = "";
var m = AddLocal(1);
return AddLocal(b: m);
static int AddLocal()
{
x[||] = AddLocal();
return x += 1;
}
}
static int AddLocal(int a = 0, int b = 0)
{
return a + b + x + [||]y.Length;
}
}
}",
@"using System;
class C
@"class C
{
void M()
int N(int x)
{
}
int N(int x){
string y = "";
var m = AddLocal(1, x: x, y: y);
return AddLocal(b: m, x: x, y: y);
x = AddLocal(x);
static int AddLocal(int x)
{
x = AddLocal(int x);
return x += 1;
}
}
static int AddLocal(int a = 0, int b = 0, int x = 0, string y = null)
{
return a + b + x + y.Length;
}
}
}", parseOptions: CSharp8ParseOptions);
}"
, parseOptions: CSharp8ParseOptions);
}
}
}
......
......@@ -1015,6 +1015,15 @@ internal class CSharpFeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Pass in captured variables as arguments.
/// </summary>
internal static string Pass_in_captured_variables_as_arguments {
get {
return ResourceManager.GetString("Pass_in_captured_variables_as_arguments", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Properties.
/// </summary>
......@@ -1548,6 +1557,16 @@ internal class CSharpFeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Warning: Adding parameters to local function declaration may produce invalid code..
/// </summary>
internal static string Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code {
get {
return ResourceManager.GetString("Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid" +
"_code", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Warning: Moving using directives may change code meaning..
/// </summary>
......
......@@ -669,4 +669,10 @@
<value>switch statement case clause</value>
<comment>{Locked="switch"}{Locked="case"} "switch" and "case" are a C# keyword and should not be localized.</comment>
</data>
<data name="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code" xml:space="preserve">
<value>Warning: Adding parameters to local function declaration may produce invalid code.</value>
</data>
<data name="Pass_in_captured_variables_as_arguments" xml:space="preserve">
<value>Pass in captured variables as arguments</value>
</data>
</root>
\ No newline at end of file
......@@ -44,9 +44,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
{
editor.ReplaceNode(
localFunction,
(current, generator) => generator.WithModifiers(
current,
generator.GetModifiers(current).WithIsStatic(true)));
(current, generator) => MakeLocalFunctionStaticHelper.AddStaticModifier(current, generator));
}
return Task.CompletedTask;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#nullable enable
using System;
using System.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
......@@ -18,11 +21,13 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
{
var (document, textSpan, cancellationToken) = context;
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var localFunction = await context.TryGetRelevantNodeAsync<LocalFunctionStatementSyntax>().ConfigureAwait(false);
if (localFunction == null)
{
return;
}
if (localFunction == default)
if (!MakeLocalFunctionStaticHelper.IsStaticLocalFunctionSupported(localFunction.SyntaxTree))
{
return;
}
......@@ -32,11 +37,18 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
return;
}
context.RegisterRefactoring(new MyCodeAction
(FeaturesResources.Make_local_function_static, c => MakeLocalFunctionStaticHelper.CreateParameterSymbolAsync(document, localFunction, c)));
var semanticModel = (await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false))!;
if (MakeLocalFunctionStaticHelper.TryGetCaputuredSymbols(localFunction, semanticModel, out var captures) &&
captures.Length > 0 &&
!captures.Any(s => s.IsThisParameter()))
{
context.RegisterRefactoring(new MyCodeAction
(FeaturesResources.Make_local_function_static, c => MakeLocalFunctionStaticHelper.MakeLocalFunctionStaticAsync(localFunction, captures, semanticModel, document, c)));
}
}
private sealed class MyCodeAction : CodeAction.DocumentChangeAction
private class MyCodeAction : CodeAction.DocumentChangeAction
{
public MyCodeAction(string title, Func<CancellationToken, Task<Document>> createChangedDocument)
: base(title, createChangedDocument)
......
......@@ -35,8 +35,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
}
var syntaxTree = context.Node.SyntaxTree;
var options = (CSharpParseOptions)syntaxTree.Options;
if (options.LanguageVersion < LanguageVersion.CSharp8)
if (!MakeLocalFunctionStaticHelper.IsStaticLocalFunctionSupported(syntaxTree))
{
return;
}
......@@ -55,9 +54,7 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
}
var semanticModel = context.SemanticModel;
var analysis = semanticModel.AnalyzeDataFlow(localFunction);
var captures = analysis.CapturedInside;
if (analysis.Succeeded && captures.Length == 0)
if (MakeLocalFunctionStaticHelper.TryGetCaputuredSymbols(localFunction, semanticModel, out var captures) && captures.Length == 0)
{
context.ReportDiagnostic(DiagnosticHelper.Create(
Descriptor,
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#nullable enable
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
......@@ -12,86 +14,120 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Wrapping;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic
{
internal sealed class MakeLocalFunctionStaticHelper
internal static class MakeLocalFunctionStaticHelper
{
internal static async Task<Document> CreateParameterSymbolAsync(Document document, LocalFunctionStatementSyntax localFunction, CancellationToken cancellationToken)
public static bool IsStaticLocalFunctionSupported(SyntaxTree tree)
=> tree.Options is CSharpParseOptions csharpOption && csharpOption.LanguageVersion >= LanguageVersion.CSharp8;
public static bool TryGetCaputuredSymbols(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, out ImmutableArray<ISymbol> captures)
{
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(true);
var localFunctionSymbol = semanticModel.GetDeclaredSymbol(localFunction, cancellationToken);
var dataFlow = semanticModel.AnalyzeDataFlow(localFunction);
var captures = dataFlow.CapturedInside;
captures = dataFlow.CapturedInside;
var parameters = CreateParameterSymbol(captures);
return dataFlow.Succeeded;
}
// Finds all the call sites of the local function
var arrayNode = await SymbolFinder.FindReferencesAsync
(localFunctionSymbol, document.Project.Solution, cancellationToken: cancellationToken).ConfigureAwait(false);
public static async Task<Document> MakeLocalFunctionStaticAsync(
LocalFunctionStatementSyntax localFunction,
ImmutableArray<ISymbol> captures,
SemanticModel semanticModel,
Document document,
CancellationToken cancellationToken)
{
var root = (await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false))!;
var rootOne = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var editor = new SyntaxEditor(rootOne, CSharpSyntaxGenerator.Instance);
var localFunctionSymbol = semanticModel.GetDeclaredSymbol(localFunction, cancellationToken);
var parameters = CreateParameterSymbols(captures);
editor.TrackNode(localFunction);
// Finds all the call sites of the local function
var referencedSymbols = await SymbolFinder.FindReferencesAsync(
localFunctionSymbol, document.Project.Solution, cancellationToken).ConfigureAwait(false);
// Now we need to find all the refereces to the local function that we might need to fix.
var shouldWarn = false;
var invocationReferences = new List<InvocationExpressionSyntax>();
var referencesBuilder = Analyzer.Utilities.PooledObjects.ArrayBuilder<InvocationExpressionSyntax>.GetInstance();
foreach (var referenceSymbol in arrayNode)
foreach (var referencedSymbol in referencedSymbols)
{
foreach (var location in referenceSymbol.Locations)
foreach (var location in referencedSymbol.Locations)
{
var root = await location.Document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var syntaxNode = root.FindNode(location.Location.SourceSpan); //Node for the identifier syntax
var invocation = (syntaxNode as IdentifierNameSyntax).Parent as InvocationExpressionSyntax;
if (invocation == null)
// Since this is a local function, all reference must be in the same tree.
var referenceNode = root.FindNode(location.Location.SourceSpan);
if (!(referenceNode is IdentifierNameSyntax identifierNode))
{
var annotation = WarningAnnotation.Create("Warning: Expression may have side effects. Code meaning may change.");
editor.ReplaceNode(syntaxNode, syntaxNode.WithAdditionalAnnotations(annotation));
continue;
}
editor.TrackNode(invocation);
referencesBuilder.Add(invocation);
if (identifierNode.Parent is InvocationExpressionSyntax invocation)
{
invocationReferences.Add(invocation);
}
else
{
// We won't be able to fix non-invocation references,
// e.g. creating a delegate.
shouldWarn = true;
}
}
}
foreach (var invocation in referencesBuilder.OrderByDescending(n => n.Span.Start))
var nodeToTrack = new List<SyntaxNode>(invocationReferences) { localFunction };
root = root.TrackNodes(nodeToTrack);
// Fix all invocations by passing in additional arguments.
foreach (var invocation in invocationReferences.OrderByDescending(n => n.Span.Start))
{
var newArguments = parameters.Select
(p => CSharpSyntaxGenerator.Instance.Argument(name: null, p.RefKind, p.Name.ToIdentifierName()) as ArgumentSyntax);
var newArgList = invocation.ArgumentList.WithArguments(invocation.ArgumentList.Arguments.AddRange(newArguments));
var newInvocation = invocation.WithArgumentList(newArgList);
editor.GetChangedRoot();
editor.ReplaceNode(invocation, newInvocation);
}
var currentInvocation = root.GetCurrentNode(invocation);
var seenNamedArgument = currentInvocation.ArgumentList.Arguments.Any(a => a.NameColon != null);
var seenDefaultArgumentValue = currentInvocation.ArgumentList.Arguments.Count < localFunction.ParameterList.Parameters.Count;
var newArguments = parameters.Select(
p => CSharpSyntaxGenerator.Instance.Argument(
seenNamedArgument || seenDefaultArgumentValue ? p.Name : null,
p.RefKind,
p.Name.ToIdentifierName()) as ArgumentSyntax);
var newArgList = currentInvocation.ArgumentList.WithArguments(currentInvocation.ArgumentList.Arguments.AddRange(newArguments));
var newInvocation = currentInvocation.WithArgumentList(newArgList);
var rootWithFixedReferences = editor.GetChangedRoot();
var localFunctionWithFixedReferences = rootWithFixedReferences.GetCurrentNode(localFunction);
var documentWithFixedReferences = document.WithSyntaxRoot(rootWithFixedReferences);
root = root.ReplaceNode(currentInvocation, newInvocation);
}
// Updates the declaration with the variables passed in
var localFunctionWithFixedDeclaration = CodeGenerator.AddParameterDeclarations(
localFunctionWithFixedReferences,
// Updates the local function declaration with variables passed in as parameters
localFunction = root.GetCurrentNode(localFunction);
var localFunctionWithNewParameters = CodeGenerator.AddParameterDeclarations(
localFunction,
parameters,
documentWithFixedReferences.Project.Solution.Workspace);
document.Project.Solution.Workspace);
if (shouldWarn)
{
var annotation = WarningAnnotation.Create(CSharpFeaturesResources.Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code);
localFunctionWithNewParameters = localFunctionWithNewParameters.WithAdditionalAnnotations(annotation);
}
// Adds the modifier static
var modifiers = DeclarationModifiers.From(localFunctionSymbol).WithIsStatic(true);
var localFunctionWithStatic = (LocalFunctionStatementSyntax)CSharpSyntaxGenerator.Instance.WithModifiers(localFunctionWithFixedDeclaration, modifiers);
var fixedLocalFunction = AddStaticModifier(localFunctionWithNewParameters, CSharpSyntaxGenerator.Instance);
var fixedRoot = root.ReplaceNode(localFunction, fixedLocalFunction);
var finalRoot = rootWithFixedReferences.ReplaceNode(localFunctionWithFixedReferences, localFunctionWithStatic);
return documentWithFixedReferences.WithSyntaxRoot(finalRoot);
return document.WithSyntaxRoot(fixedRoot);
}
// Creates a new parameter symbol for all variables captured in the local function
static ImmutableArray<IParameterSymbol> CreateParameterSymbol(ImmutableArray<ISymbol> captures)
public static SyntaxNode AddStaticModifier(SyntaxNode localFunction, SyntaxGenerator generator)
=> generator.WithModifiers(
localFunction,
generator.GetModifiers(localFunction).WithIsStatic(true));
/// <summary>
/// Creates a new parameter symbol for each captured variables.
/// </summary>
private static ImmutableArray<IParameterSymbol> CreateParameterSymbols(ImmutableArray<ISymbol> captures)
{
var parameters = ArrayBuilder<IParameterSymbol>.GetInstance(captures.Length);
......@@ -104,6 +140,7 @@ static ImmutableArray<IParameterSymbol> CreateParameterSymbol(ImmutableArray<ISy
type: symbol.GetSymbolType(),
name: symbol.Name.ToCamelCase()));
}
return parameters.ToImmutableAndFree();
}
}
......
......@@ -14,48 +14,51 @@
namespace Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic
{
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(PassVariableExplicitlyInLocalStaticFunctionCodeFixProvider)), Shared]
internal sealed class PassVariableExplicitlyInLocalStaticFunctionCodeFixProvider : CodeFixProvider
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(PassInCapturedVariablesAsArgumentsCodeFixProvider)), Shared]
internal sealed class PassInCapturedVariablesAsArgumentsCodeFixProvider : CodeFixProvider
{
[ImportingConstructor]
public PassVariableExplicitlyInLocalStaticFunctionCodeFixProvider()
{
}
public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create("CS8421");
public sealed override FixAllProvider GetFixAllProvider()
public override FixAllProvider GetFixAllProvider()
{
// See https://github.com/dotnet/roslyn/blob/master/docs/analyzers/FixAllProvider.md for more information on Fix All Providers
return WellKnownFixAllProviders.BatchFixer;
return null;
}
public override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
var diagnostic = context.Diagnostics.First();
var diagnosticSpan = diagnostic.Location.SourceSpan;
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
var localFunction = root.FindNode(diagnosticSpan).AncestorsAndSelf().OfType<LocalFunctionStatementSyntax>().First();
var declaration = root.FindNode(diagnosticSpan).AncestorsAndSelf().OfType<LocalFunctionStatementSyntax>().First();
if (localFunction == null)
{
return;
}
if (declaration == null)
if (!MakeLocalFunctionStaticHelper.IsStaticLocalFunctionSupported(localFunction.SyntaxTree))
{
return;
}
var document = context.Document;
var cancellationToken = context.CancellationToken;
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
context.RegisterCodeFix(
new MyCodeAction(c => MakeLocalFunctionStaticHelper.CreateParameterSymbolAsync(context.Document, declaration, c)),
diagnostic);
if (MakeLocalFunctionStaticHelper.TryGetCaputuredSymbols(localFunction, semanticModel, out var captures) &&
captures.Length > 0 &&
!captures.Any(s => s.IsThisParameter()))
{
context.RegisterCodeFix(
new MyCodeAction(c => MakeLocalFunctionStaticHelper.MakeLocalFunctionStaticAsync(localFunction, captures, semanticModel, document, c)),
diagnostic);
}
}
private class MyCodeAction : CodeAction.DocumentChangeAction
{
public MyCodeAction(Func<CancellationToken, Task<Document>> createChangedDocument)
: base(FeaturesResources.Pass_variable_explicitly, createChangedDocument, FeaturesResources.Pass_variable_explicitly)
: base(CSharpFeaturesResources.Pass_in_captured_variables_as_arguments, createChangedDocument, CSharpFeaturesResources.Pass_in_captured_variables_as_arguments)
{
}
}
......
......@@ -112,6 +112,11 @@
<target state="translated">Nastavit jako ref struct</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">Odebrat nepotřebná přetypování</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">"ref struct" erstellen</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">Nicht erforderliche Umwandlungen entfernen</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="translated">"{0}" ist hier nicht NULL.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">Convertir "ref struct"</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">Quitar conversiones innecesarias</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">Définir 'ref struct'</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">Supprimer les casts inutiles</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">Imposta come 'ref struct'</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">Rimuovi i cast non necessari</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">'ref struct' を作成します</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">不要なキャストを削除する</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">'ref struct'로 지정</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">불필요한 캐스트 제거</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">Ustaw jako „ref struct”</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">Usuń niepotrzebne rzutowania</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">Alterar 'ref struct'</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">Remover conversões desnecessárias</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">Сделать ref struct</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">Удалить ненужные приведения</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">'ref struct' yap</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">Gereksiz atamaları kaldır</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">生成 "ref struct"</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">删除不必要的转换</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -112,6 +112,11 @@
<target state="translated">設為 'ref struct'</target>
<note>{Locked="ref"}{Locked="struct"} "ref" and "struct" are C# keywords and should not be localized.</note>
</trans-unit>
<trans-unit id="Pass_in_captured_variables_as_arguments">
<source>Pass in captured variables as arguments</source>
<target state="new">Pass in captured variables as arguments</target>
<note />
</trans-unit>
<trans-unit id="Remove_unnecessary_casts">
<source>Remove unnecessary casts</source>
<target state="translated">移除不必要的 Cast</target>
......@@ -162,6 +167,11 @@
<target state="new">Warning: Inlining temporary into conditional method call.</target>
<note />
</trans-unit>
<trans-unit id="Warning_colon_Adding_parameters_to_local_function_declaration_may_produce_invalid_code">
<source>Warning: Adding parameters to local function declaration may produce invalid code.</source>
<target state="new">Warning: Adding parameters to local function declaration may produce invalid code.</target>
<note />
</trans-unit>
<trans-unit id="_0_is_not_null_here">
<source>'{0}' is not null here.</source>
<target state="new">'{0}' is not null here.</target>
......
......@@ -2983,15 +2983,6 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Pass in values explicitly.
/// </summary>
internal static string Pass_variable_explicitly {
get {
return ResourceManager.GetString("Pass_variable_explicitly", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;Pending&gt;.
/// </summary>
......
......@@ -1696,7 +1696,4 @@ This version used in: {2}</value>
<data name="Add_null_checks_for_all_parameters" xml:space="preserve">
<value>Add null checks for all parameters</value>
</data>
<data name="Pass_variable_explicitly" xml:space="preserve">
<value>Pass in values explicitly</value>
</data>
</root>
\ No newline at end of file
......@@ -322,11 +322,6 @@
<target state="translated">Přesunout do oboru názvů...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">Soukromý člen {0} se může odebrat, jak jeho přiřazená hodnota se nikdy nečte.</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">In Namespace verschieben...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">Der private Member "{0}" kann entfernt werden, da der zugewiesene Wert nie gelesen wird.</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">Mover a espacio de nombres...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">Un miembro privado "{0}" puede retirarse porque el valor asignado a él no se lee nunca.</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">Déplacer vers un espace de noms...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">Vous pouvez supprimer le membre privé '{0}', car la valeur qui lui est attribuée n'est jamais lue.</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">Sposta nello spazio dei nomi...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">È possibile rimuovere il membro privato '{0}' perché il valore assegnato ad esso non viene mai letto.</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">名前空間に移動します...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">割り当てられている値が読み取られることがないようにプライベートメンバー '{0}' を削除できます。</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">네임스페이스로 이동...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">Private 멤버 '{0}'에 할당된 값을 읽을 수 없으므로 이 멤버를 제거할 수 있습니다.</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">Przenieś do przestrzeni nazw...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">Prywatną składową „{0}” można usunąć, ponieważ przypisana do niej wartość nie jest nigdy odczytywana.</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">Mover para o namespace...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">O membro particular '{0}' pode ser removido pois o valor atribuído a ele nunca é lido.</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">Переместить в пространство имен...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">Закрытый член «{0}» может быть удален как значение, присвоенное него никогда не читал.</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">Ad alanına taşı...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">Kendisine atanmış değeri hiç okurken özel üye '{0}'-ebilmek var olmak çıkarmak.</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">移动到命名空间...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">可删除私有成员“{0}”,因为永不会读取分配给它的值。</target>
......
......@@ -322,11 +322,6 @@
<target state="translated">移到命名空間...</target>
<note />
</trans-unit>
<trans-unit id="Pass_variable_explicitly">
<source>Pass in values explicitly</source>
<target state="new">Pass in values explicitly</target>
<note />
</trans-unit>
<trans-unit id="Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read">
<source>Private member '{0}' can be removed as the value assigned to it is never read.</source>
<target state="translated">因為永遠不會讀取指派給私用成員 '{0}' 的值,所以可移除該成員。</target>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册