Welcome to mirror list, hosted at ThFree Co, Russian Federation.

StringBuilder.Debug.cs « Text « System « shared « System.Private.CoreLib « src - github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a62c4777adb33d71e350b1820ef3ccf349fdff74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Diagnostics;

namespace System.Text
{
    public sealed partial class StringBuilder
    {
        private void ShowChunks(int maxChunksToShow = 10)
        {
            int count = 0;
            StringBuilder head = this, current = this;
            while (current != null)
            {
                if (count < maxChunksToShow)
                {
                    count++;
                }
                else
                {
                    head = head.m_ChunkPrevious;
                }
                current = current.m_ChunkPrevious;
            }
            current = head;
            string[] chunks = new string[count];
            for (int i = count; i > 0; i--)
            {
                chunks[i - 1] = new string(current.m_ChunkChars).Replace('\0', '.');
                current = current.m_ChunkPrevious;
            }
            Debug.WriteLine('|' + string.Join('|', chunks) + '|');
        }
    }
}