コード例 #1
0
        /// <summary>
        /// Returns true if the expression is composed only of nested tuple, declaration expressions and discards.
        /// </summary>
        internal static bool IsDeconstructionDeclarationLeft(this Syntax.InternalSyntax.ExpressionSyntax node)
        {
            switch (node.Kind)
            {
            case SyntaxKind.TupleExpression:
                var arguments = ((Syntax.InternalSyntax.TupleExpressionSyntax)node).Arguments;
                for (int i = 0; i < arguments.Count; i++)
                {
                    if (!IsDeconstructionDeclarationLeft(arguments[i].Expression))
                    {
                        return(false);
                    }
                }

                return(true);

            case SyntaxKind.DeclarationExpression:
                return(true);

            case SyntaxKind.IdentifierName:
                // Underscore is the only expression that is not clearly a declaration that we tolerate for now
                return(node.RawContextualKind == (int)SyntaxKind.UnderscoreToken);

            default:
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Returns true if the expression is composed only of nested tuple and declaration expressions.
        /// </summary>
        internal static bool IsDeconstructionDeclarationLeft(this Syntax.InternalSyntax.ExpressionSyntax node)
        {
            switch (node.Kind)
            {
            case SyntaxKind.TupleExpression:
                var arguments = ((Syntax.InternalSyntax.TupleExpressionSyntax)node).Arguments;
                for (int i = 0; i < arguments.Count; i++)
                {
                    if (!IsDeconstructionDeclarationLeft(arguments[i].Expression))
                    {
                        return(false);
                    }
                }

                return(true);

            case SyntaxKind.DeclarationExpression:
                return(true);

            default:
                return(false);
            }
        }