private static void ThrowIfContainsNonStringLiteralExpression(StringConcatenationAnalysis analysis)
 {
     if (analysis.ContainsNonStringLiteral)
     {
         throw new InvalidOperationException("String concatenation contains an expression that is not a string literal.");
     }
 }
        internal LiteralExpressionSyntax ToStringLiteralExpression()
        {
            ThrowInvalidOperationIfNotInitialized();

            StringConcatenationAnalysis analysis = Analyze();

            ThrowIfContainsNonStringLiteralExpression(analysis);

            StringBuilder sb = StringBuilderCache.GetInstance();

            if (!analysis.ContainsNonVerbatimExpression)
            {
                sb.Append('@');
            }

            sb.Append('"');

            foreach (ExpressionSyntax expression in Expressions(leftToRight: true))
            {
                StringLiteralExpressionInfo literal = SyntaxInfo.StringLiteralExpressionInfo(expression);

                if (literal.Success)
                {
                    if (analysis.ContainsNonVerbatimExpression && literal.IsVerbatim)
                    {
                        int startIndex = sb.Length;
                        sb.Append(literal.ValueText);
                        sb.Replace(@"\", @"\\", startIndex);
                        sb.Replace("\"", @"\" + "\"", startIndex);
                        sb.Replace("\n", @"\n", startIndex);
                        sb.Replace("\r", @"\r", startIndex);
                    }
                    else
                    {
                        sb.Append(literal.InnerText);
                    }
                }
            }

            sb.Append('"');

            return((LiteralExpressionSyntax)ParseExpression(StringBuilderCache.GetStringAndFree(sb)));
        }
 internal StringConcatenationAnalysis Analyze()
 {
     return(StringConcatenationAnalysis.Create(this));
 }