|
1 | | -using System.Data; |
| 1 | +using System.Data; |
2 | 2 | using System.Globalization; |
3 | 3 | using ICSharpCode.CodeConverter.CSharp.Replacements; |
4 | 4 | using ICSharpCode.CodeConverter.Util.FromRoslyn; |
@@ -688,19 +688,14 @@ private static QualifiedNameSyntax Qualify(string qualification, ExpressionSynta |
688 | 688 |
|
689 | 689 | private static bool IsSubPartOfConditionalAccess(VBasic.Syntax.MemberAccessExpressionSyntax node) |
690 | 690 | { |
691 | | - static bool IsMemberAccessChain(SyntaxNode exp) => |
692 | | - exp?.IsKind(VBasic.SyntaxKind.InvocationExpression, |
693 | | - VBasic.SyntaxKind.SimpleMemberAccessExpression, |
694 | | - VBasic.SyntaxKind.ParenthesizedExpression, |
695 | | - VBasic.SyntaxKind.ConditionalAccessExpression) == true; |
696 | | - |
697 | | - for (SyntaxNode child = node, parent = node.Parent; IsMemberAccessChain(parent); child = parent, parent = parent.Parent) { |
698 | | - if (parent is VBSyntax.ConditionalAccessExpressionSyntax cae && cae.WhenNotNull == child) { |
699 | | - return true; // On right hand side of a ?. conditional access |
700 | | - } |
| 691 | + var firstPossiblyConditionalAncestor = node.Parent; |
| 692 | + while (firstPossiblyConditionalAncestor != null && |
| 693 | + firstPossiblyConditionalAncestor.IsKind(VBasic.SyntaxKind.InvocationExpression, |
| 694 | + VBasic.SyntaxKind.SimpleMemberAccessExpression)) { |
| 695 | + firstPossiblyConditionalAncestor = firstPossiblyConditionalAncestor.Parent; |
701 | 696 | } |
702 | 697 |
|
703 | | - return false; |
| 698 | + return firstPossiblyConditionalAncestor?.IsKind(VBasic.SyntaxKind.ConditionalAccessExpression) == true; |
704 | 699 | } |
705 | 700 |
|
706 | 701 | private static CSharpSyntaxNode ReplaceRightmostIdentifierText(CSharpSyntaxNode expr, SyntaxToken idToken, string overrideIdentifier) |
|
0 commit comments