提交 4162f451 编写于 作者: B Balaji Krishnan

PR Feedback: Add more test and code formatting

Fixed code styles and added one more test.
上级 d7b717a1
......@@ -277,6 +277,49 @@ public T F<T>(T x)
{
return F(new C())?.F(new C())?.Extn();
}
}";
Test(initialText, expectedText, isLine: false);
}
[WorkItem(3818, "https://github.com/dotnet/roslyn/issues/3818")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddUsing)]
public void InExtensionMethodUnderMultipleConditionalAccessExpressions2()
{
var initialText =
@"<Workspace>
<Project Language=""C#"" AssemblyName=""CSAssembly"" CommonReferences=""true"">
<Document FilePath = ""Program"">
public class C
{
public T F&lt;T&gt;(T x)
{
return F(new C())?.F(new C())[|.Extn()|]?.F(newC());
}
}
</Document>
<Document FilePath = ""Extensions"">
namespace Sample.Extensions
{
public static class Extensions
{
public static C Extn(this C obj)
{
return obj.F(new C());
}
}
}
</Document>
</Project>
</Workspace>";
var expectedText =
@"using Sample.Extensions;
public class C
{
public T F<T>(T x)
{
return F(new C())?.F(new C()).Extn()?.F(newC());
}
}";
Test(initialText, expectedText, isLine: false);
}
......
......@@ -555,9 +555,9 @@ public void GetNameAndArityOfSimpleName(SyntaxNode node, out string name, out in
public SyntaxNode GetExpressionOfMemberAccessExpression(SyntaxNode node)
{
return node.IsKind(SyntaxKind.MemberBindingExpression) ?
GetExpressionOfConditionalMemberAccessExpression(node.GetParentConditionalAccessExpression()) :
(node as MemberAccessExpressionSyntax)?.Expression;
return node.IsKind(SyntaxKind.MemberBindingExpression)
? GetExpressionOfConditionalMemberAccessExpression(node.GetParentConditionalAccessExpression())
: (node as MemberAccessExpressionSyntax)?.Expression;
}
public SyntaxNode GetExpressionOfConditionalMemberAccessExpression(SyntaxNode node)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册