提交 d313659b 编写于 作者: N Nishanth Pradeep

Remove this recommendation for anonymous functions in static methods

上级 6da27094
......@@ -342,6 +342,230 @@ void nested()
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInAnonymousMethod()
{
await VerifyKeywordAsync(
@"class C
{
int Method()
{
Action a = delegate
{
$$
};
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedAnonymousMethod()
{
await VerifyKeywordAsync(
@"class C
{
int Method()
{
Action a = delegate
{
Action b = delegate
{
$$
};
};
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInAnonymousMethodInStaticMethod()
{
await VerifyAbsenceAsync(
@"class C
{
static int Method()
{
Action a = delegate
{
$$
};
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedAnonymousMethodInStaticMethod()
{
await VerifyAbsenceAsync(
@"class C
{
static int Method()
{
Action a = delegate
{
Action b = delegate
{
$$
};
};
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInLambdaExpression()
{
await VerifyKeywordAsync(
@"class C
{
int Method()
{
Action a = () =>
{
$$
};
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedLambdaExpression()
{
await VerifyKeywordAsync(
@"class C
{
int Method()
{
Action a = () =>
{
Action b = () =>
{
$$
};
};
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInLambdaExpressionInStaticMethod()
{
await VerifyAbsenceAsync(
@"class C
{
static int Method()
{
Action a = () =>
{
$$
};
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedLambdaExpressionInStaticMethod()
{
await VerifyAbsenceAsync(
@"class C
{
static int Method()
{
Action a = () =>
{
Action b = () =>
{
$$
};
};
}
}");
}
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedLambdaExpressionInAnonymousMethod()
{
await VerifyKeywordAsync(
@"class C
{
int Method()
{
Action a = delegate
{
Action b = () =>
{
$$
};
};
}
}");
}
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedAnonymousInLambdaExpression()
{
await VerifyKeywordAsync(
@"class C
{
int Method()
{
Action a = () =>
{
Action b = delegate
{
$$
};
};
}
}");
}
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedAnonymousMethodInLambdaExpressionInStaticMethod()
{
await VerifyAbsenceAsync(
@"class C
{
static int Method()
{
Action a = () =>
{
Action b = delegate
{
$$
};
};
}
}");
}
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedLambdaExpressionInAnonymousMethodInStaticMethod()
{
await VerifyAbsenceAsync(
@"class C
{
static int Method()
{
Action a = delegate
{
Action b = () =>
{
$$
};
};
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
public async Task TestAfterAttribute()
{
......
......@@ -1772,7 +1772,7 @@ public static bool IsInstanceContext(this SyntaxTree syntaxTree, SyntaxToken tar
var enclosingSymbol = semanticModel.GetEnclosingSymbol(targetToken.SpanStart, cancellationToken);
while (enclosingSymbol is IMethodSymbol method && method.MethodKind == MethodKind.LocalFunction)
while (enclosingSymbol is IMethodSymbol method && (method.MethodKind == MethodKind.LocalFunction || method.MethodKind == MethodKind.AnonymousFunction))
{
// It is allowed to reference the instance (`this`) within a local function, as long as the containing method allows it
enclosingSymbol = method.ContainingSymbol;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册