StringBuilder.Debug.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Diagnostics;
  5. namespace System.Text
  6. {
  7. public sealed partial class StringBuilder
  8. {
  9. private void ShowChunks(int maxChunksToShow = 10)
  10. {
  11. int count = 0;
  12. StringBuilder head = this, current = this;
  13. while (current != null)
  14. {
  15. if (count < maxChunksToShow)
  16. {
  17. count++;
  18. }
  19. else
  20. {
  21. head = head.m_ChunkPrevious;
  22. }
  23. current = current.m_ChunkPrevious;
  24. }
  25. current = head;
  26. string[] chunks = new string[count];
  27. for (int i = count; i > 0; i--)
  28. {
  29. chunks[i - 1] = new string(current.m_ChunkChars).Replace('\0', '.');
  30. current = current.m_ChunkPrevious;
  31. }
  32. Debug.WriteLine('|' + string.Join('|', chunks) + '|');
  33. }
  34. }
  35. }