Exemplo n.º 1
0
#pragma warning restore GU0073 // Member of non-public type should be internal.

        internal static bool Uses(ExpressionSyntax assigned, ExpressionSyntax returned, SyntaxNodeAnalysisContext context, PooledSet <SyntaxNode>?visited = null)
        {
            if (assigned is null ||
                returned is null)
            {
                return(false);
            }

            using (var assignedPath = MemberPath.PathWalker.Borrow(assigned))
            {
                var containingType = context.ContainingSymbol.ContainingType;
                if (UsedMemberWalker.Uses(returned, assignedPath, Search.TopLevel, containingType, context.SemanticModel, context.CancellationToken))
                {
                    return(true);
                }

                if (assignedPath.Tokens.TrySingle(out var candidate) &&
                    containingType.TryFindPropertyRecursive(candidate.ValueText, out var property) &&
                    property.TrySingleDeclaration(context.CancellationToken, out var declaration) &&
                    declaration.TryGetSetter(out var setter) &&
                    Setter.TryFindSingleAssignment(setter, out var assignment))
                {
                    using var set = visited.IncrementUsage();
                    if (set.Add(candidate.Parent))
                    {
                        return(Uses(assignment.Left, returned, context, set));
                    }
                }
            }

            return(false);
        }
Exemplo n.º 2
0
 internal static bool Uses(SyntaxNode scope, MemberPath.PathWalker memberPath, SyntaxNodeAnalysisContext context)
 {
     return(UsedMemberWalker.Uses(scope, memberPath, Search.Recursive, context.ContainingSymbol.ContainingType, context.SemanticModel, context.CancellationToken));
 }