示例#1
0
        public static ArrayCreationExpressionSyntax CreateArray(ArrayTypeSyntax arrayType, ValueBridge size)
        {
            var rankSpecifiers    = arrayType.RankSpecifiers;
            var newRankSpecifiers = rankSpecifiers.Select((x, i)
                                                          => i == 0 ? SyntaxFactory.ArrayRankSpecifier(SyntaxFactoryHelper.CreateSeparatedList((ExpressionSyntax)size)) : x);

            return(SyntaxFactory.ArrayCreationExpression(
                       arrayType.WithRankSpecifiers(new SyntaxList <ArrayRankSpecifierSyntax>(newRankSpecifiers))));
        }
 public static ArrayTypeSyntax WithOmittedRankSpecifiers(this ArrayTypeSyntax syntax) =>
 syntax.WithRankSpecifiers(
     SingletonList(
         ArrayRankSpecifier(
             SingletonSeparatedList <ExpressionSyntax>(
                 OmittedArraySizeExpression()
                 )
             )
         )
     );