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

Added tests to see if this is offered (or not) correctly in lambdas contained within properties

上级 542523bc
......@@ -490,6 +490,7 @@ static int Method()
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedLambdaExpressionInAnonymousMethod()
{
......@@ -509,6 +510,7 @@ int Method()
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedAnonymousInLambdaExpression()
{
......@@ -528,6 +530,7 @@ int Method()
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedAnonymousMethodInLambdaExpressionInStaticMethod()
{
......@@ -547,6 +550,7 @@ static int Method()
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedLambdaExpressionInAnonymousMethodInStaticMethod()
{
......@@ -566,6 +570,34 @@ static int Method()
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedLambdaExpressionInAProperty()
{
await VerifyKeywordAsync(
@"class C
{
Action A
{
get { return delegate { $$ } }
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
[WorkItem(27923, "https://github.com/dotnet/roslyn/issues/27923")]
public async Task TestInNestedLambdaExpressionInAStaticProperty()
{
await VerifyAbsenceAsync(
@"class C
{
static Action A
{
get { return delegate { $$ } }
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
public async Task TestAfterAttribute()
{
......
......@@ -1772,10 +1772,10 @@ public static bool IsInstanceContext(this SyntaxTree syntaxTree, SyntaxToken tar
var enclosingSymbol = semanticModel.GetEnclosingSymbol(targetToken.SpanStart, cancellationToken);
while (enclosingSymbol is IMethodSymbol method && enclosingSymbol.ContainingSymbol is IMethodSymbol)
while (enclosingSymbol is IMethodSymbol && enclosingSymbol.ContainingSymbol is IMethodSymbol)
{
// It is allowed to reference the instance (`this`) within a local function or anonymous function, as long as the containing method allows it
enclosingSymbol = method.ContainingSymbol;
enclosingSymbol = enclosingSymbol.ContainingSymbol;
}
return !enclosingSymbol.IsStatic;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册