Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StringBuilder.cs
Go to the documentation of this file.
8
9namespace System.Text;
10
12[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
13public sealed class StringBuilder : ISerializable
14{
15 public struct ChunkEnumerator
16 {
17 private sealed class ManyChunkInfo
18 {
19 private readonly StringBuilder[] _chunks;
20
21 private int _chunkPos;
22
23 public bool MoveNext(ref StringBuilder current)
24 {
25 int num = ++_chunkPos;
26 if (_chunks.Length <= num)
27 {
28 return false;
29 }
30 current = _chunks[num];
31 return true;
32 }
33
35 {
37 while (0 <= --chunkCount)
38 {
40 stringBuilder = stringBuilder.m_ChunkPrevious;
41 }
42 _chunkPos = -1;
43 }
44 }
45
46 private readonly StringBuilder _firstChunk;
47
49
50 private readonly ManyChunkInfo _manyChunks;
51
63
66 {
67 return this;
68 }
69
70 public bool MoveNext()
71 {
73 {
74 return false;
75 }
76 if (_manyChunks != null)
77 {
79 }
81 while (stringBuilder.m_ChunkPrevious != _currentChunk)
82 {
83 stringBuilder = stringBuilder.m_ChunkPrevious;
84 }
86 return true;
87 }
88
90 {
92 _currentChunk = null;
93 _manyChunks = null;
94 int num = ChunkCount(stringBuilder);
95 if (8 < num)
96 {
98 }
99 }
100
102 {
103 int num = 0;
104 while (stringBuilder != null)
105 {
106 num++;
107 stringBuilder = stringBuilder.m_ChunkPrevious;
108 }
109 return num;
110 }
111 }
112
116 {
117 internal readonly StringBuilder _stringBuilder;
118
119 private readonly IFormatProvider _provider;
120
121 private readonly bool _hasCustomFormatter;
122
129
136
137 public void AppendLiteral(string value)
138 {
140 }
141
143 {
145 {
147 }
148 else if (value is IFormattable)
149 {
151 {
154 {
155 if ((uint)charsWritten > (uint)remainingCurrentChunk.Length)
156 {
157 FormatError();
158 }
160 }
161 else
162 {
164 }
165 }
166 else
167 {
169 }
170 }
171 else if (value != null)
172 {
173 _stringBuilder.Append(value.ToString());
174 }
175 }
176
177 public void AppendFormatted<T>(T value, string? format)
178 {
180 {
182 }
183 else if (value is IFormattable)
184 {
186 {
189 {
190 if ((uint)charsWritten > (uint)remainingCurrentChunk.Length)
191 {
192 FormatError();
193 }
195 }
196 else
197 {
199 }
200 }
201 else
202 {
204 }
205 }
206 else if (value != null)
207 {
208 _stringBuilder.Append(value.ToString());
209 }
210 }
211
213 {
215 }
216
217 public void AppendFormatted<T>(T value, int alignment, string? format)
218 {
219 if (alignment == 0)
220 {
222 }
223 else if (alignment < 0)
224 {
227 int num = -alignment - (_stringBuilder.Length - length);
228 if (num > 0)
229 {
230 _stringBuilder.Append(' ', num);
231 }
232 }
233 else
234 {
236 }
237 }
238
248
253
254 public void AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string? format = null)
255 {
256 if (alignment == 0)
257 {
259 return;
260 }
261 bool flag = false;
262 if (alignment < 0)
263 {
264 flag = true;
266 }
267 int num = alignment - value.Length;
268 if (num <= 0)
269 {
271 }
272 else if (flag)
273 {
275 _stringBuilder.Append(' ', num);
276 }
277 else
278 {
279 _stringBuilder.Append(' ', num);
281 }
282 }
283
284 public void AppendFormatted(string? value)
285 {
287 {
289 }
290 else
291 {
292 this.AppendFormatted<string>(value);
293 }
294 }
295
296 public void AppendFormatted(string? value, int alignment = 0, string? format = null)
297 {
299 }
300
301 public void AppendFormatted(object? value, int alignment = 0, string? format = null)
302 {
304 }
305
306 [MethodImpl(MethodImplOptions.NoInlining)]
315 }
316
317 internal char[] m_ChunkChars;
318
320
321 internal int m_ChunkLength;
322
323 internal int m_ChunkOffset;
324
325 internal int m_MaxCapacity;
326
327 public int Capacity
328 {
329 get
330 {
332 }
333 set
334 {
335 if (value < 0)
336 {
338 }
339 if (value > MaxCapacity)
340 {
342 }
343 if (value < Length)
344 {
346 }
347 if (Capacity != value)
348 {
349 int length = value - m_ChunkOffset;
350 char[] array = GC.AllocateUninitializedArray<char>(length);
353 }
354 }
355 }
356
358
359 public int Length
360 {
361 get
362 {
364 }
365 set
366 {
367 if (value < 0)
368 {
370 }
371 if (value > MaxCapacity)
372 {
374 }
375 if (value == 0 && m_ChunkPrevious == null)
376 {
377 m_ChunkLength = 0;
378 m_ChunkOffset = 0;
379 return;
380 }
381 int num = value - Length;
382 if (num > 0)
383 {
384 Append('\0', num);
385 return;
386 }
388 if (stringBuilder != this)
389 {
390 int num2 = Math.Min(Capacity, Math.Max(Length * 6 / 5, m_ChunkChars.Length));
391 int num3 = num2 - stringBuilder.m_ChunkOffset;
392 if (num3 > stringBuilder.m_ChunkChars.Length)
393 {
394 char[] array = GC.AllocateUninitializedArray<char>(num3);
395 Array.Copy(stringBuilder.m_ChunkChars, array, stringBuilder.m_ChunkLength);
397 }
398 else
399 {
400 m_ChunkChars = stringBuilder.m_ChunkChars;
401 }
402 m_ChunkPrevious = stringBuilder.m_ChunkPrevious;
403 m_ChunkOffset = stringBuilder.m_ChunkOffset;
404 }
405 m_ChunkLength = value - stringBuilder.m_ChunkOffset;
406 }
407 }
408
409 [IndexerName("Chars")]
410 public char this[int index]
411 {
412 get
413 {
415 do
416 {
417 int num = index - stringBuilder.m_ChunkOffset;
418 if (num >= 0)
419 {
420 if (num >= stringBuilder.m_ChunkLength)
421 {
422 throw new IndexOutOfRangeException();
423 }
424 return stringBuilder.m_ChunkChars[num];
425 }
426 stringBuilder = stringBuilder.m_ChunkPrevious;
427 }
428 while (stringBuilder != null);
429 throw new IndexOutOfRangeException();
430 }
431 set
432 {
434 do
435 {
436 int num = index - stringBuilder.m_ChunkOffset;
437 if (num >= 0)
438 {
439 if (num >= stringBuilder.m_ChunkLength)
440 {
442 }
443 stringBuilder.m_ChunkChars[num] = value;
444 return;
445 }
446 stringBuilder = stringBuilder.m_ChunkPrevious;
447 }
448 while (stringBuilder != null);
450 }
451 }
452
454 {
455 [MethodImpl(MethodImplOptions.AggressiveInlining)]
456 get
457 {
459 }
460 }
461
463 {
464 int num = Capacity;
465 if (num < requiredCapacity)
466 {
467 num = (requiredCapacity + 1) & -2;
468 }
469 return num;
470 }
471
472 internal unsafe void ReplaceBufferInternal(char* newBuffer, int newLength)
473 {
475 {
477 }
478 if (newLength > m_ChunkChars.Length)
479 {
481 }
484 m_ChunkPrevious = null;
485 m_ChunkOffset = 0;
486 }
487
489 {
490 if (source.Length > m_MaxCapacity)
491 {
493 }
494 int charCount = Encoding.UTF8.GetCharCount(source);
495 if (charCount > m_ChunkChars.Length)
496 {
498 }
500 m_ChunkPrevious = null;
501 m_ChunkOffset = 0;
502 }
503
504 internal unsafe void ReplaceBufferAnsiInternal(sbyte* newBuffer, int newLength)
505 {
507 {
509 }
510 if (newLength > m_ChunkChars.Length)
511 {
513 }
514 int chunkLength;
516 {
518 }
519 m_ChunkOffset = 0;
521 m_ChunkPrevious = null;
522 }
523
524 internal unsafe void InternalCopy(IntPtr dest, int charLen)
525 {
526 CopyTo(0, new Span<char>((void*)dest, charLen), charLen);
527 }
528
530 {
531 m_MaxCapacity = int.MaxValue;
532 m_ChunkChars = new char[16];
533 }
534
536 : this(capacity, int.MaxValue)
537 {
538 }
539
540 public StringBuilder(string? value)
541 : this(value, 16)
542 {
543 }
544
545 public StringBuilder(string? value, int capacity)
546 : this(value, 0, value?.Length ?? 0, capacity)
547 {
548 }
549
550 public StringBuilder(string? value, int startIndex, int length, int capacity)
551 {
552 if (capacity < 0)
553 {
555 }
556 if (length < 0)
557 {
559 }
560 if (startIndex < 0)
561 {
563 }
564 if (value == null)
565 {
566 value = string.Empty;
567 }
568 if (startIndex > value.Length - length)
569 {
571 }
572 m_MaxCapacity = int.MaxValue;
573 if (capacity == 0)
574 {
575 capacity = 16;
576 }
578 m_ChunkChars = GC.AllocateUninitializedArray<char>(capacity);
580 value.AsSpan(startIndex, length).CopyTo(m_ChunkChars);
581 }
582
584 {
585 if (capacity > maxCapacity)
586 {
588 }
589 if (maxCapacity < 1)
590 {
592 }
593 if (capacity < 0)
594 {
596 }
597 if (capacity == 0)
598 {
600 }
602 m_ChunkChars = GC.AllocateUninitializedArray<char>(capacity);
603 }
604
606 {
607 if (info == null)
608 {
609 throw new ArgumentNullException("info");
610 }
611 int num = 0;
612 string text = null;
613 int num2 = int.MaxValue;
614 bool flag = false;
616 while (enumerator.MoveNext())
617 {
618 switch (enumerator.Name)
619 {
620 case "m_MaxCapacity":
621 num2 = info.GetInt32("m_MaxCapacity");
622 break;
623 case "m_StringValue":
624 text = info.GetString("m_StringValue");
625 break;
626 case "Capacity":
627 num = info.GetInt32("Capacity");
628 flag = true;
629 break;
630 }
631 }
632 if (text == null)
633 {
634 text = string.Empty;
635 }
637 {
639 }
640 if (!flag)
641 {
642 num = Math.Min(Math.Max(16, text.Length), num2);
643 }
644 if (num < 0 || num < text.Length || num > num2)
645 {
647 }
649 m_ChunkChars = GC.AllocateUninitializedArray<char>(num);
650 text.CopyTo(0, m_ChunkChars, 0, text.Length);
651 m_ChunkLength = text.Length;
652 }
653
655 {
656 if (info == null)
657 {
658 throw new ArgumentNullException("info");
659 }
660 info.AddValue("m_MaxCapacity", m_MaxCapacity);
661 info.AddValue("Capacity", Capacity);
662 info.AddValue("m_StringValue", ToString());
663 info.AddValue("m_currentThread", 0);
664 }
665
666 public int EnsureCapacity(int capacity)
667 {
668 if (capacity < 0)
669 {
671 }
672 if (Capacity < capacity)
673 {
675 }
676 return Capacity;
677 }
678
679 public override string ToString()
680 {
681 if (Length == 0)
682 {
683 return string.Empty;
684 }
685 string text = string.FastAllocateString(Length);
687 do
688 {
689 if (stringBuilder.m_ChunkLength > 0)
690 {
691 char[] chunkChars = stringBuilder.m_ChunkChars;
692 int chunkOffset = stringBuilder.m_ChunkOffset;
693 int chunkLength = stringBuilder.m_ChunkLength;
694 if ((uint)(chunkLength + chunkOffset) > (uint)text.Length || (uint)chunkLength > (uint)chunkChars.Length)
695 {
697 }
699 }
700 stringBuilder = stringBuilder.m_ChunkPrevious;
701 }
702 while (stringBuilder != null);
703 return text;
704 }
705
706 public unsafe string ToString(int startIndex, int length)
707 {
708 int length2 = Length;
709 if (startIndex < 0)
710 {
712 }
713 if (startIndex > length2)
714 {
716 }
717 if (length < 0)
718 {
720 }
721 if (startIndex > length2 - length)
722 {
724 }
725 string text = string.FastAllocateString(length);
726 fixed (char* pointer = text)
727 {
729 return text;
730 }
731 }
732
734 {
735 Length = 0;
736 return this;
737 }
738
740 {
741 return new ChunkEnumerator(this);
742 }
743
744 public StringBuilder Append(char value, int repeatCount)
745 {
746 if (repeatCount < 0)
747 {
749 }
750 if (repeatCount == 0)
751 {
752 return this;
753 }
754 int num = Length + repeatCount;
755 if (num > m_MaxCapacity || num < repeatCount)
756 {
758 }
759 int num2 = m_ChunkLength;
760 while (repeatCount > 0)
761 {
762 if (num2 < m_ChunkChars.Length)
763 {
765 repeatCount--;
766 }
767 else
768 {
770 ExpandByABlock(repeatCount);
771 num2 = 0;
772 }
773 }
775 return this;
776 }
777
778 public unsafe StringBuilder Append(char[]? value, int startIndex, int charCount)
779 {
780 if (startIndex < 0)
781 {
783 }
784 if (charCount < 0)
785 {
787 }
788 if (value == null)
789 {
790 if (startIndex == 0 && charCount == 0)
791 {
792 return this;
793 }
794 throw new ArgumentNullException("value");
795 }
796 if (charCount > value.Length - startIndex)
797 {
799 }
800 if (charCount == 0)
801 {
802 return this;
803 }
804 fixed (char* value2 = &value[startIndex])
805 {
807 return this;
808 }
809 }
810
811 public StringBuilder Append(string? value)
812 {
813 if (value != null)
814 {
815 char[] chunkChars = m_ChunkChars;
817 int length = value.Length;
818 if ((uint)(chunkLength + length) < (uint)chunkChars.Length)
819 {
820 if (length <= 2)
821 {
822 if (length > 0)
823 {
825 }
826 if (length > 1)
827 {
828 chunkChars[chunkLength + 1] = value[1];
829 }
830 }
831 else
832 {
834 }
836 }
837 else
838 {
840 }
841 }
842 return this;
843 }
844
845 private unsafe void AppendHelper(string value)
846 {
847 fixed (char* value2 = value)
848 {
849 Append(value2, value.Length);
850 }
851 }
852
853 public unsafe StringBuilder Append(string? value, int startIndex, int count)
854 {
855 if (startIndex < 0)
856 {
858 }
859 if (count < 0)
860 {
862 }
863 if (value == null)
864 {
865 if (startIndex == 0 && count == 0)
866 {
867 return this;
868 }
869 throw new ArgumentNullException("value");
870 }
871 if (count == 0)
872 {
873 return this;
874 }
875 if (startIndex > value.Length - count)
876 {
878 }
879 fixed (char* ptr = value)
880 {
882 return this;
883 }
884 }
885
887 {
888 if (value != null && value.Length != 0)
889 {
890 return AppendCore(value, 0, value.Length);
891 }
892 return this;
893 }
894
896 {
897 if (startIndex < 0)
898 {
900 }
901 if (count < 0)
902 {
904 }
905 if (value == null)
906 {
907 if (startIndex == 0 && count == 0)
908 {
909 return this;
910 }
911 throw new ArgumentNullException("value");
912 }
913 if (count == 0)
914 {
915 return this;
916 }
917 if (count > value.Length - startIndex)
918 {
920 }
922 }
923
925 {
926 if (value == this)
927 {
928 return Append(value.ToString(startIndex, count));
929 }
930 int num = Length + count;
931 if ((uint)num > (uint)m_MaxCapacity)
932 {
934 }
935 while (count > 0)
936 {
937 int num2 = Math.Min(m_ChunkChars.Length - m_ChunkLength, count);
938 if (num2 == 0)
939 {
942 }
945 startIndex += num2;
946 count -= num2;
947 }
948 return this;
949 }
950
952 {
953 return Append(Environment.NewLine);
954 }
955
957 {
958 Append(value);
959 return Append(Environment.NewLine);
960 }
961
962 public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
963 {
964 if (destination == null)
965 {
966 throw new ArgumentNullException("destination");
967 }
968 if (destinationIndex < 0)
969 {
970 throw new ArgumentOutOfRangeException("destinationIndex", SR.Format(SR.ArgumentOutOfRange_MustBeNonNegNum, "destinationIndex"));
971 }
972 if (destinationIndex > destination.Length - count)
973 {
975 }
977 }
978
980 {
981 if (count < 0)
982 {
984 }
985 if ((uint)sourceIndex > (uint)Length)
986 {
988 }
989 if (sourceIndex > Length - count)
990 {
992 }
994 int num = sourceIndex + count;
995 int num2 = count;
996 while (count > 0)
997 {
998 int num3 = num - stringBuilder.m_ChunkOffset;
999 if (num3 >= 0)
1000 {
1001 num3 = Math.Min(num3, stringBuilder.m_ChunkLength);
1002 int num4 = count;
1003 int num5 = num3 - count;
1004 if (num5 < 0)
1005 {
1006 num4 += num5;
1007 num5 = 0;
1008 }
1009 num2 -= num4;
1010 count -= num4;
1011 new ReadOnlySpan<char>(stringBuilder.m_ChunkChars, num5, num4).CopyTo(destination.Slice(num2));
1012 }
1013 stringBuilder = stringBuilder.m_ChunkPrevious;
1014 }
1015 }
1016
1017 public unsafe StringBuilder Insert(int index, string? value, int count)
1018 {
1019 if (count < 0)
1020 {
1022 }
1023 int length = Length;
1024 if ((uint)index > (uint)length)
1025 {
1027 }
1028 if (string.IsNullOrEmpty(value) || count == 0)
1029 {
1030 return this;
1031 }
1032 long num = (long)value.Length * (long)count;
1033 if (num > MaxCapacity - Length)
1034 {
1035 throw new OutOfMemoryException();
1036 }
1038 fixed (char* value2 = value)
1039 {
1040 while (count > 0)
1041 {
1043 count--;
1044 }
1045 return this;
1046 }
1047 }
1048
1050 {
1051 if (length < 0)
1052 {
1054 }
1055 if (startIndex < 0)
1056 {
1058 }
1059 if (length > Length - startIndex)
1060 {
1062 }
1063 if (Length == length && startIndex == 0)
1064 {
1065 Length = 0;
1066 return this;
1067 }
1068 if (length > 0)
1069 {
1071 }
1072 return this;
1073 }
1074
1076 {
1077 return Append(value.ToString());
1078 }
1079
1081 {
1083 char[] chunkChars = m_ChunkChars;
1084 if ((uint)chunkChars.Length > (uint)chunkLength)
1085 {
1087 m_ChunkLength++;
1088 }
1089 else
1090 {
1091 Append(value, 1);
1092 }
1093 return this;
1094 }
1095
1096 [CLSCompliant(false)]
1098 {
1100 }
1101
1103 {
1105 }
1106
1108 {
1110 }
1111
1113 {
1115 }
1116
1118 {
1120 }
1121
1123 {
1125 }
1126
1128 {
1130 }
1131
1133 {
1135 }
1136
1137 [CLSCompliant(false)]
1139 {
1141 }
1142
1143 [CLSCompliant(false)]
1145 {
1147 }
1148
1149 [CLSCompliant(false)]
1151 {
1153 }
1154
1156 {
1157 if (value.TryFormat(RemainingCurrentChunk, out var charsWritten, default(ReadOnlySpan<char>), null))
1158 {
1160 return this;
1161 }
1162 return Append(value.ToString());
1163 }
1164
1166 {
1168 {
1170 return this;
1171 }
1172 return Append(value.ToString(format, provider));
1173 }
1174
1176 {
1177 if (value != null)
1178 {
1179 return Append(value.ToString());
1180 }
1181 return this;
1182 }
1183
1184 public unsafe StringBuilder Append(char[]? value)
1185 {
1186 if (value != null && value.Length != 0)
1187 {
1188 fixed (char* value2 = &value[0])
1189 {
1190 Append(value2, value.Length);
1191 }
1192 }
1193 return this;
1194 }
1195
1197 {
1198 if (value.Length > 0)
1199 {
1200 fixed (char* value2 = &MemoryMarshal.GetReference(value))
1201 {
1202 Append(value2, value.Length);
1203 }
1204 }
1205 return this;
1206 }
1207
1209 {
1210 return Append(value.Span);
1211 }
1212
1217
1218 public StringBuilder Append(IFormatProvider? provider, [InterpolatedStringHandlerArgument(new string[] { "", "provider" })] ref AppendInterpolatedStringHandler handler)
1219 {
1220 return this;
1221 }
1222
1227
1228 public StringBuilder AppendLine(IFormatProvider? provider, [InterpolatedStringHandlerArgument(new string[] { "", "provider" })] ref AppendInterpolatedStringHandler handler)
1229 {
1230 return AppendLine();
1231 }
1232
1233 public unsafe StringBuilder AppendJoin(string? separator, params object?[] values)
1234 {
1235 if (separator == null)
1236 {
1237 separator = string.Empty;
1238 }
1239 fixed (char* separator2 = separator)
1240 {
1241 return AppendJoinCore(separator2, separator.Length, values);
1242 }
1243 }
1244
1246 {
1247 if (separator == null)
1248 {
1249 separator = string.Empty;
1250 }
1251 fixed (char* separator2 = separator)
1252 {
1253 return AppendJoinCore(separator2, separator.Length, values);
1254 }
1255 }
1256
1257 public unsafe StringBuilder AppendJoin(string? separator, params string?[] values)
1258 {
1259 if (separator == null)
1260 {
1261 separator = string.Empty;
1262 }
1263 fixed (char* separator2 = separator)
1264 {
1265 return AppendJoinCore(separator2, separator.Length, values);
1266 }
1267 }
1268
1269 public unsafe StringBuilder AppendJoin(char separator, params object?[] values)
1270 {
1271 return AppendJoinCore(&separator, 1, values);
1272 }
1273
1275 {
1276 return AppendJoinCore(&separator, 1, values);
1277 }
1278
1279 public unsafe StringBuilder AppendJoin(char separator, params string?[] values)
1280 {
1281 return AppendJoinCore(&separator, 1, values);
1282 }
1283
1285 {
1286 if (values == null)
1287 {
1289 }
1291 if (!enumerator.MoveNext())
1292 {
1293 return this;
1294 }
1295 T current = enumerator.Current;
1296 if (current != null)
1297 {
1298 Append(current.ToString());
1299 }
1300 while (enumerator.MoveNext())
1301 {
1303 current = enumerator.Current;
1304 if (current != null)
1305 {
1306 Append(current.ToString());
1307 }
1308 }
1309 return this;
1310 }
1311
1313 {
1314 if (values == null)
1315 {
1317 }
1318 if (values.Length == 0)
1319 {
1320 return this;
1321 }
1322 if (values[0] != null)
1323 {
1324 Append(values[0].ToString());
1325 }
1326 for (int i = 1; i < values.Length; i++)
1327 {
1329 if (values[i] != null)
1330 {
1331 Append(values[i].ToString());
1332 }
1333 }
1334 return this;
1335 }
1336
1337 public unsafe StringBuilder Insert(int index, string? value)
1338 {
1339 if ((uint)index > (uint)Length)
1340 {
1342 }
1343 if (value != null)
1344 {
1345 fixed (char* value2 = value)
1346 {
1347 Insert(index, value2, value.Length);
1348 }
1349 }
1350 return this;
1351 }
1352
1354 {
1355 return Insert(index, value.ToString(), 1);
1356 }
1357
1358 [CLSCompliant(false)]
1359 public StringBuilder Insert(int index, sbyte value)
1360 {
1361 return Insert(index, value.ToString(), 1);
1362 }
1363
1365 {
1366 return Insert(index, value.ToString(), 1);
1367 }
1368
1369 public StringBuilder Insert(int index, short value)
1370 {
1371 return Insert(index, value.ToString(), 1);
1372 }
1373
1374 public unsafe StringBuilder Insert(int index, char value)
1375 {
1376 Insert(index, &value, 1);
1377 return this;
1378 }
1379
1380 public StringBuilder Insert(int index, char[]? value)
1381 {
1382 if ((uint)index > (uint)Length)
1383 {
1385 }
1386 if (value != null)
1387 {
1388 Insert(index, value, 0, value.Length);
1389 }
1390 return this;
1391 }
1392
1393 public unsafe StringBuilder Insert(int index, char[]? value, int startIndex, int charCount)
1394 {
1395 int length = Length;
1396 if ((uint)index > (uint)length)
1397 {
1399 }
1400 if (value == null)
1401 {
1402 if (startIndex == 0 && charCount == 0)
1403 {
1404 return this;
1405 }
1406 throw new ArgumentNullException("value", SR.ArgumentNull_String);
1407 }
1408 if (startIndex < 0)
1409 {
1411 }
1412 if (charCount < 0)
1413 {
1415 }
1416 if (startIndex > value.Length - charCount)
1417 {
1419 }
1420 if (charCount > 0)
1421 {
1422 fixed (char* value2 = &value[startIndex])
1423 {
1425 }
1426 }
1427 return this;
1428 }
1429
1431 {
1432 return Insert(index, value.ToString(), 1);
1433 }
1434
1436 {
1437 return Insert(index, value.ToString(), 1);
1438 }
1439
1440 public StringBuilder Insert(int index, float value)
1441 {
1442 return Insert(index, value.ToString(), 1);
1443 }
1444
1445 public StringBuilder Insert(int index, double value)
1446 {
1447 return Insert(index, value.ToString(), 1);
1448 }
1449
1450 public StringBuilder Insert(int index, decimal value)
1451 {
1452 return Insert(index, value.ToString(), 1);
1453 }
1454
1455 [CLSCompliant(false)]
1456 public StringBuilder Insert(int index, ushort value)
1457 {
1458 return Insert(index, value.ToString(), 1);
1459 }
1460
1461 [CLSCompliant(false)]
1463 {
1464 return Insert(index, value.ToString(), 1);
1465 }
1466
1467 [CLSCompliant(false)]
1468 public StringBuilder Insert(int index, ulong value)
1469 {
1470 return Insert(index, value.ToString(), 1);
1471 }
1472
1473 public StringBuilder Insert(int index, object? value)
1474 {
1475 if (value != null)
1476 {
1477 return Insert(index, value.ToString(), 1);
1478 }
1479 return this;
1480 }
1481
1483 {
1484 if ((uint)index > (uint)Length)
1485 {
1487 }
1488 if (value.Length > 0)
1489 {
1490 fixed (char* value2 = &MemoryMarshal.GetReference(value))
1491 {
1492 Insert(index, value2, value.Length);
1493 }
1494 }
1495 return this;
1496 }
1497
1498 public StringBuilder AppendFormat(string format, object? arg0)
1499 {
1500 return AppendFormatHelper(null, format, new ParamsArray(arg0));
1501 }
1502
1503 public StringBuilder AppendFormat(string format, object? arg0, object? arg1)
1504 {
1505 return AppendFormatHelper(null, format, new ParamsArray(arg0, arg1));
1506 }
1507
1508 public StringBuilder AppendFormat(string format, object? arg0, object? arg1, object? arg2)
1509 {
1510 return AppendFormatHelper(null, format, new ParamsArray(arg0, arg1, arg2));
1511 }
1512
1513 public StringBuilder AppendFormat(string format, params object?[] args)
1514 {
1515 if (args == null)
1516 {
1517 string paramName = ((format == null) ? "format" : "args");
1519 }
1520 return AppendFormatHelper(null, format, new ParamsArray(args));
1521 }
1522
1527
1529 {
1531 }
1532
1533 public StringBuilder AppendFormat(IFormatProvider? provider, string format, object? arg0, object? arg1, object? arg2)
1534 {
1536 }
1537
1539 {
1540 if (args == null)
1541 {
1542 string paramName = ((format == null) ? "format" : "args");
1544 }
1546 }
1547
1548 private static void FormatError()
1549 {
1551 }
1552
1554 {
1555 if (format == null)
1556 {
1557 throw new ArgumentNullException("format");
1558 }
1559 int num = 0;
1560 int length = format.Length;
1561 char c = '\0';
1563 if (provider != null)
1564 {
1566 }
1567 while (true)
1568 {
1569 if (num < length)
1570 {
1571 c = format[num];
1572 num++;
1573 if (c == '}')
1574 {
1575 if (num < length && format[num] == '}')
1576 {
1577 num++;
1578 }
1579 else
1580 {
1581 FormatError();
1582 }
1583 }
1584 else if (c == '{')
1585 {
1586 if (num >= length || format[num] != '{')
1587 {
1588 num--;
1589 goto IL_008f;
1590 }
1591 num++;
1592 }
1593 Append(c);
1594 continue;
1595 }
1596 goto IL_008f;
1597 IL_008f:
1598 if (num == length)
1599 {
1600 break;
1601 }
1602 num++;
1603 if (num == length || (c = format[num]) < '0' || c > '9')
1604 {
1605 FormatError();
1606 }
1607 int num2 = 0;
1608 do
1609 {
1610 num2 = num2 * 10 + c - 48;
1611 num++;
1612 if (num == length)
1613 {
1614 FormatError();
1615 }
1616 c = format[num];
1617 }
1618 while (c >= '0' && c <= '9' && num2 < 1000000);
1619 if (num2 >= args.Length)
1620 {
1622 }
1623 for (; num < length; num++)
1624 {
1625 if ((c = format[num]) != ' ')
1626 {
1627 break;
1628 }
1629 }
1630 bool flag = false;
1631 int num3 = 0;
1632 if (c == ',')
1633 {
1634 for (num++; num < length && format[num] == ' '; num++)
1635 {
1636 }
1637 if (num == length)
1638 {
1639 FormatError();
1640 }
1641 c = format[num];
1642 if (c == '-')
1643 {
1644 flag = true;
1645 num++;
1646 if (num == length)
1647 {
1648 FormatError();
1649 }
1650 c = format[num];
1651 }
1652 if (c < '0' || c > '9')
1653 {
1654 FormatError();
1655 }
1656 do
1657 {
1658 num3 = num3 * 10 + c - 48;
1659 num++;
1660 if (num == length)
1661 {
1662 FormatError();
1663 }
1664 c = format[num];
1665 }
1666 while (c >= '0' && c <= '9' && num3 < 1000000);
1667 }
1668 for (; num < length; num++)
1669 {
1670 if ((c = format[num]) != ' ')
1671 {
1672 break;
1673 }
1674 }
1675 object obj = args[num2];
1677 switch (c)
1678 {
1679 case ':':
1680 {
1681 num++;
1682 int num4 = num;
1683 while (true)
1684 {
1685 if (num == length)
1686 {
1687 FormatError();
1688 }
1689 c = format[num];
1690 switch (c)
1691 {
1692 case '{':
1693 FormatError();
1694 goto IL_0205;
1695 default:
1696 goto IL_0205;
1697 case '}':
1698 break;
1699 }
1700 break;
1701 IL_0205:
1702 num++;
1703 }
1704 if (num > num4)
1705 {
1706 readOnlySpan = format.AsSpan(num4, num - num4);
1707 }
1708 break;
1709 }
1710 default:
1711 FormatError();
1712 break;
1713 case '}':
1714 break;
1715 }
1716 num++;
1717 string text = null;
1718 string text2 = null;
1719 if (customFormatter != null)
1720 {
1721 if (readOnlySpan.Length != 0)
1722 {
1723 text2 = new string(readOnlySpan);
1724 }
1726 }
1727 if (text == null)
1728 {
1730 {
1731 if ((uint)charsWritten > (uint)RemainingCurrentChunk.Length)
1732 {
1733 FormatError();
1734 }
1736 int num5 = num3 - charsWritten;
1737 if (flag && num5 > 0)
1738 {
1739 Append(' ', num5);
1740 }
1741 continue;
1742 }
1744 {
1745 if (readOnlySpan.Length != 0 && text2 == null)
1746 {
1747 text2 = new string(readOnlySpan);
1748 }
1749 text = formattable.ToString(text2, provider);
1750 }
1751 else if (obj != null)
1752 {
1753 text = obj.ToString();
1754 }
1755 }
1756 if (text == null)
1757 {
1758 text = string.Empty;
1759 }
1760 int num6 = num3 - text.Length;
1761 if (!flag && num6 > 0)
1762 {
1763 Append(' ', num6);
1764 }
1765 Append(text);
1766 if (flag && num6 > 0)
1767 {
1768 Append(' ', num6);
1769 }
1770 }
1771 return this;
1772 }
1773
1774 public StringBuilder Replace(string oldValue, string? newValue)
1775 {
1776 return Replace(oldValue, newValue, 0, Length);
1777 }
1778
1779 public bool Equals([NotNullWhen(true)] StringBuilder? sb)
1780 {
1781 if (sb == null)
1782 {
1783 return false;
1784 }
1785 if (Length != sb.Length)
1786 {
1787 return false;
1788 }
1789 if (sb == this)
1790 {
1791 return true;
1792 }
1794 int num = stringBuilder.m_ChunkLength;
1796 int num2 = stringBuilder2.m_ChunkLength;
1797 do
1798 {
1799 num--;
1800 num2--;
1801 while (num < 0)
1802 {
1803 stringBuilder = stringBuilder.m_ChunkPrevious;
1804 if (stringBuilder == null)
1805 {
1806 break;
1807 }
1808 num = stringBuilder.m_ChunkLength + num;
1809 }
1810 while (num2 < 0)
1811 {
1812 stringBuilder2 = stringBuilder2.m_ChunkPrevious;
1813 if (stringBuilder2 == null)
1814 {
1815 break;
1816 }
1818 }
1819 if (num < 0)
1820 {
1821 return num2 < 0;
1822 }
1823 if (num2 < 0)
1824 {
1825 return false;
1826 }
1827 }
1828 while (stringBuilder.m_ChunkChars[num] == stringBuilder2.m_ChunkChars[num2]);
1829 return false;
1830 }
1831
1833 {
1834 if (span.Length != Length)
1835 {
1836 return false;
1837 }
1839 int num = 0;
1840 do
1841 {
1842 int chunkLength = stringBuilder.m_ChunkLength;
1843 num += chunkLength;
1845 if (!span2.EqualsOrdinal(span.Slice(span.Length - num, chunkLength)))
1846 {
1847 return false;
1848 }
1849 stringBuilder = stringBuilder.m_ChunkPrevious;
1850 }
1851 while (stringBuilder != null);
1852 return true;
1853 }
1854
1855 public StringBuilder Replace(string oldValue, string? newValue, int startIndex, int count)
1856 {
1857 int length = Length;
1858 if ((uint)startIndex > (uint)length)
1859 {
1861 }
1863 {
1865 }
1866 if (oldValue == null)
1867 {
1868 throw new ArgumentNullException("oldValue");
1869 }
1870 if (oldValue.Length == 0)
1871 {
1872 throw new ArgumentException(SR.Argument_EmptyName, "oldValue");
1873 }
1874 if (newValue == null)
1875 {
1876 newValue = string.Empty;
1877 }
1878 int[] array = null;
1879 int num = 0;
1881 int num2 = startIndex - stringBuilder.m_ChunkOffset;
1882 while (count > 0)
1883 {
1885 {
1886 if (array == null)
1887 {
1888 array = new int[5];
1889 }
1890 else if (num >= array.Length)
1891 {
1892 Array.Resize(ref array, array.Length * 3 / 2 + 4);
1893 }
1894 array[num++] = num2;
1895 num2 += oldValue.Length;
1896 count -= oldValue.Length;
1897 }
1898 else
1899 {
1900 num2++;
1901 count--;
1902 }
1903 if (num2 >= stringBuilder.m_ChunkLength || count == 0)
1904 {
1905 int num3 = num2 + stringBuilder.m_ChunkOffset;
1907 num3 += (newValue.Length - oldValue.Length) * num;
1908 num = 0;
1910 num2 = num3 - stringBuilder.m_ChunkOffset;
1911 }
1912 }
1913 return this;
1914 }
1915
1917 {
1918 return Replace(oldChar, newChar, 0, Length);
1919 }
1920
1922 {
1923 int length = Length;
1924 if ((uint)startIndex > (uint)length)
1925 {
1927 }
1929 {
1931 }
1932 int num = startIndex + count;
1934 while (true)
1935 {
1936 int num2 = num - stringBuilder.m_ChunkOffset;
1937 int num3 = startIndex - stringBuilder.m_ChunkOffset;
1938 if (num2 >= 0)
1939 {
1940 int i = Math.Max(num3, 0);
1941 for (int num4 = Math.Min(stringBuilder.m_ChunkLength, num2); i < num4; i++)
1942 {
1943 if (stringBuilder.m_ChunkChars[i] == oldChar)
1944 {
1945 stringBuilder.m_ChunkChars[i] = newChar;
1946 }
1947 }
1948 }
1949 if (num3 >= 0)
1950 {
1951 break;
1952 }
1953 stringBuilder = stringBuilder.m_ChunkPrevious;
1954 }
1955 return this;
1956 }
1957
1958 [CLSCompliant(false)]
1959 public unsafe StringBuilder Append(char* value, int valueCount)
1960 {
1961 if (valueCount < 0)
1962 {
1964 }
1965 int num = Length + valueCount;
1966 if (num > m_MaxCapacity || num < valueCount)
1967 {
1969 }
1971 if (num2 <= m_ChunkChars.Length)
1972 {
1975 }
1976 else
1977 {
1979 if (num3 > 0)
1980 {
1982 m_ChunkLength = m_ChunkChars.Length;
1983 }
1984 int num4 = valueCount - num3;
1988 }
1989 return this;
1990 }
1991
1992 private unsafe void Insert(int index, char* value, int valueCount)
1993 {
1994 if ((uint)index > (uint)Length)
1995 {
1997 }
1998 if (valueCount > 0)
1999 {
2002 }
2003 }
2004
2006 {
2007 if (replacementsCount <= 0)
2008 {
2009 return;
2010 }
2011 fixed (char* value2 = value)
2012 {
2013 long num = (long)(value.Length - removeCount) * (long)replacementsCount;
2014 int num2 = (int)num;
2015 if (num2 != num)
2016 {
2017 throw new OutOfMemoryException();
2018 }
2020 int indexInChunk = replacements[0];
2021 if (num2 > 0)
2022 {
2024 }
2025 int num3 = 0;
2026 while (true)
2027 {
2030 num3++;
2031 if (num3 >= replacementsCount)
2032 {
2033 break;
2034 }
2035 int num5 = replacements[num3];
2036 if (num2 != 0)
2037 {
2038 fixed (char* value3 = &sourceChunk.m_ChunkChars[num4])
2039 {
2041 }
2042 }
2043 else
2044 {
2045 indexInChunk += num5 - num4;
2046 }
2047 }
2048 if (num2 < 0)
2049 {
2050 Remove(chunk.m_ChunkOffset + indexInChunk, -num2, out chunk, out indexInChunk);
2051 }
2052 }
2053 }
2054
2055 private bool StartsWith(StringBuilder chunk, int indexInChunk, int count, string value)
2056 {
2057 for (int i = 0; i < value.Length; i++)
2058 {
2059 if (count == 0)
2060 {
2061 return false;
2062 }
2063 if (indexInChunk >= chunk.m_ChunkLength)
2064 {
2065 chunk = Next(chunk);
2066 if (chunk == null)
2067 {
2068 return false;
2069 }
2070 indexInChunk = 0;
2071 }
2072 if (value[i] != chunk.m_ChunkChars[indexInChunk])
2073 {
2074 return false;
2075 }
2076 indexInChunk++;
2077 count--;
2078 }
2079 return true;
2080 }
2081
2083 {
2084 if (count == 0)
2085 {
2086 return;
2087 }
2088 while (true)
2089 {
2091 int num = Math.Min(val, count);
2092 new ReadOnlySpan<char>(value, num).CopyTo(chunk.m_ChunkChars.AsSpan(indexInChunk));
2093 indexInChunk += num;
2094 if (indexInChunk >= chunk.m_ChunkLength)
2095 {
2096 chunk = Next(chunk);
2097 indexInChunk = 0;
2098 }
2099 count -= num;
2100 if (count != 0)
2101 {
2102 value += num;
2103 continue;
2104 }
2105 break;
2106 }
2107 }
2108
2110 {
2112 while (stringBuilder.m_ChunkOffset > index)
2113 {
2114 stringBuilder = stringBuilder.m_ChunkPrevious;
2115 }
2116 return stringBuilder;
2117 }
2118
2120 {
2121 if (chunk != this)
2122 {
2123 return FindChunkForIndex(chunk.m_ChunkOffset + chunk.m_ChunkLength);
2124 }
2125 return null;
2126 }
2127
2129 {
2131 {
2133 }
2134 int num = Math.Max(minBlockCharCount, Math.Min(Length, 8000));
2135 if (m_ChunkOffset + m_ChunkLength + num < num)
2136 {
2137 throw new OutOfMemoryException();
2138 }
2139 char[] chunkChars = GC.AllocateUninitializedArray<char>(num);
2140 m_ChunkPrevious = new StringBuilder(this);
2142 m_ChunkLength = 0;
2144 }
2145
2147 {
2148 m_ChunkLength = from.m_ChunkLength;
2149 m_ChunkOffset = from.m_ChunkOffset;
2150 m_ChunkChars = from.m_ChunkChars;
2151 m_ChunkPrevious = from.m_ChunkPrevious;
2152 m_MaxCapacity = from.m_MaxCapacity;
2153 }
2154
2156 {
2157 if (count + Length > m_MaxCapacity || count + Length < count)
2158 {
2160 }
2161 chunk = this;
2162 while (chunk.m_ChunkOffset > index)
2163 {
2165 chunk = chunk.m_ChunkPrevious;
2166 }
2167 indexInChunk = index - chunk.m_ChunkOffset;
2168 if (!doNotMoveFollowingChars && chunk.m_ChunkLength <= 32 && chunk.m_ChunkChars.Length - chunk.m_ChunkLength >= count)
2169 {
2170 int num = chunk.m_ChunkLength;
2171 while (num > indexInChunk)
2172 {
2173 num--;
2174 chunk.m_ChunkChars[num + count] = chunk.m_ChunkChars[num];
2175 }
2177 return;
2178 }
2179 StringBuilder stringBuilder = new StringBuilder(Math.Max(count, 16), chunk.m_MaxCapacity, chunk.m_ChunkPrevious);
2181 int num2 = Math.Min(count, indexInChunk);
2182 if (num2 > 0)
2183 {
2184 new ReadOnlySpan<char>(chunk.m_ChunkChars, 0, num2).CopyTo(stringBuilder.m_ChunkChars);
2185 int num3 = indexInChunk - num2;
2186 if (num3 >= 0)
2187 {
2188 new ReadOnlySpan<char>(chunk.m_ChunkChars, num2, num3).CopyTo(chunk.m_ChunkChars);
2190 }
2191 }
2194 if (num2 < count)
2195 {
2198 }
2199 }
2200
2202 {
2203 m_ChunkChars = GC.AllocateUninitializedArray<char>(size);
2206 if (previousBlock != null)
2207 {
2209 }
2210 }
2211
2213 {
2214 int num = startIndex + count;
2215 chunk = this;
2217 int num2 = 0;
2218 while (true)
2219 {
2220 if (num - chunk.m_ChunkOffset >= 0)
2221 {
2222 if (stringBuilder == null)
2223 {
2225 num2 = num - stringBuilder.m_ChunkOffset;
2226 }
2227 if (startIndex - chunk.m_ChunkOffset >= 0)
2228 {
2229 break;
2230 }
2231 }
2232 else
2233 {
2235 }
2236 chunk = chunk.m_ChunkPrevious;
2237 }
2238 indexInChunk = startIndex - chunk.m_ChunkOffset;
2239 int num3 = indexInChunk;
2241 if (stringBuilder != chunk)
2242 {
2243 num3 = 0;
2247 if (indexInChunk == 0)
2248 {
2249 stringBuilder.m_ChunkPrevious = chunk.m_ChunkPrevious;
2251 }
2252 }
2254 if (num3 != num2)
2255 {
2256 new ReadOnlySpan<char>(stringBuilder.m_ChunkChars, num2, length).CopyTo(stringBuilder.m_ChunkChars.AsSpan(num3));
2257 }
2258 }
2259}
static unsafe int MultiByteToWideChar(uint CodePage, uint dwFlags, byte *lpMultiByteStr, int cbMultiByte, char *lpWideCharStr, int cchWideChar)
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static void Memmove(ref byte dest, ref byte src, nuint len)
Definition Buffer.cs:215
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
static string NewLine
Definition GC.cs:8
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static unsafe ref byte GetArrayDataReference(Array array)
static string ArgumentOutOfRange_Index
Definition SR.cs:30
static string ArgumentOutOfRange_NegativeCount
Definition SR.cs:1080
static string ArgumentOutOfRange_SmallCapacity
Definition SR.cs:34
static string ArgumentOutOfRange_Capacity
Definition SR.cs:984
static string Arg_LongerThanSrcString
Definition SR.cs:232
static string Format_IndexOutOfRange
Definition SR.cs:1348
static string ArgumentOutOfRange_NegativeLength
Definition SR.cs:1082
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ArgumentOutOfRange_MustBePositive
Definition SR.cs:1068
static string ArgumentOutOfRange_NegativeCapacity
Definition SR.cs:1078
static string ArgumentOutOfRange_LengthGreaterThanCapacity
Definition SR.cs:1050
static string ArgumentOutOfRange_StartIndex
Definition SR.cs:1106
static string ArgumentOutOfRange_SmallMaxCapacity
Definition SR.cs:1104
static string ArgumentOutOfRange_StartIndexLargerThanLength
Definition SR.cs:1108
static string ArgumentOutOfRange_MustBeNonNegNum
Definition SR.cs:1066
static string Serialization_StringBuilderMaxCapacity
Definition SR.cs:1908
static string Format_InvalidString
Definition SR.cs:1354
static string Serialization_StringBuilderCapacity
Definition SR.cs:1906
static string Argument_EmptyName
Definition SR.cs:584
static string ArgumentOutOfRange_GenericPositive
Definition SR.cs:1018
static string ArgumentOutOfRange_IndexLength
Definition SR.cs:1034
static string ArgumentOutOfRange_OffsetOut
Definition SR.cs:1086
static string Arg_NegativeArgCount
Definition SR.cs:332
static string ArgumentNull_String
Definition SR.cs:960
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
Definition SR.cs:7
static Encoding UTF8
Definition Encoding.cs:526
ManyChunkInfo(StringBuilder stringBuilder, int chunkCount)
bool Equals([NotNullWhen(true)] StringBuilder? sb)
StringBuilder Insert(int index, byte value)
StringBuilder Insert(int index, float value)
StringBuilder Append(ulong value)
StringBuilder Insert(int index, decimal value)
StringBuilder Append(ReadOnlyMemory< char > value)
StringBuilder AppendFormat(string format, object? arg0, object? arg1, object? arg2)
StringBuilder Append(bool value)
StringBuilder Insert(int index, long value)
StringBuilder Append(decimal value)
StringBuilder Append(StringBuilder? value)
unsafe void ReplaceInPlaceAtChunk(ref StringBuilder chunk, ref int indexInChunk, char *value, int count)
bool StartsWith(StringBuilder chunk, int indexInChunk, int count, string value)
StringBuilder Insert(int index, bool value)
StringBuilder FindChunkForIndex(int index)
StringBuilder Insert(int index, uint value)
StringBuilder Insert(int index, int value)
unsafe StringBuilder AppendJoin(char separator, params string?[] values)
unsafe string ToString(int startIndex, int length)
StringBuilder(SerializationInfo info, StreamingContext context)
StringBuilder Next(StringBuilder chunk)
StringBuilder AppendLine(string? value)
StringBuilder AppendCore(StringBuilder value, int startIndex, int count)
StringBuilder Append(double value)
unsafe StringBuilder AppendJoin(string? separator, params object?[] values)
unsafe StringBuilder AppendJoin(string? separator, params string?[] values)
StringBuilder Append(StringBuilder? value, int startIndex, int count)
StringBuilder AppendFormat(IFormatProvider? provider, string format, object? arg0, object? arg1, object? arg2)
StringBuilder Insert(int index, object? value)
StringBuilder Append(int value)
StringBuilder AppendFormat(string format, params object?[] args)
StringBuilder Append(uint value)
StringBuilder(int capacity, int maxCapacity)
StringBuilder Append(byte value)
StringBuilder AppendFormat(string format, object? arg0, object? arg1)
StringBuilder Append(long value)
StringBuilder AppendSpanFormattable< T >(T value)
unsafe StringBuilder Insert(int index, string? value)
unsafe StringBuilder AppendJoin(char separator, params object?[] values)
int EnsureCapacity(int capacity)
unsafe void Insert(int index, char *value, int valueCount)
unsafe StringBuilder Insert(int index, ReadOnlySpan< char > value)
StringBuilder Replace(char oldChar, char newChar)
int GetReplaceBufferCapacity(int requiredCapacity)
StringBuilder Insert(int index, ulong value)
StringBuilder Insert(int index, char[]? value)
StringBuilder Insert(int index, ushort value)
ChunkEnumerator GetChunks()
StringBuilder Append(object? value)
void ReplaceBufferUtf8Internal(ReadOnlySpan< byte > source)
StringBuilder AppendLine(IFormatProvider? provider, [InterpolatedStringHandlerArgument(new string[] { "", "provider" })] ref AppendInterpolatedStringHandler handler)
bool Equals(ReadOnlySpan< char > span)
void Remove(int startIndex, int count, out StringBuilder chunk, out int indexInChunk)
StringBuilder AppendFormat(IFormatProvider? provider, string format, object? arg0, object? arg1)
StringBuilder Append(short value)
StringBuilder AppendFormat(IFormatProvider? provider, string format, params object?[] args)
StringBuilder Insert(int index, double value)
StringBuilder Replace(string oldValue, string? newValue, int startIndex, int count)
unsafe StringBuilder Insert(int index, string? value, int count)
StringBuilder Append(string? value)
StringBuilder Insert(int index, sbyte value)
StringBuilder(string? value, int capacity)
unsafe StringBuilder AppendJoin< T >(string? separator, IEnumerable< T > values)
StringBuilder(StringBuilder from)
unsafe void AppendHelper(string value)
unsafe StringBuilder Append(char[]? value, int startIndex, int charCount)
unsafe StringBuilder Append(ReadOnlySpan< char > value)
StringBuilder Insert(int index, short value)
unsafe void ReplaceAllInChunk(int[] replacements, int replacementsCount, StringBuilder sourceChunk, int removeCount, string value)
StringBuilder Remove(int startIndex, int length)
void ExpandByABlock(int minBlockCharCount)
unsafe void ReplaceBufferAnsiInternal(sbyte *newBuffer, int newLength)
void CopyTo(int sourceIndex, Span< char > destination, int count)
StringBuilder AppendLine([InterpolatedStringHandlerArgument("")] ref AppendInterpolatedStringHandler handler)
StringBuilder(string? value, int startIndex, int length, int capacity)
unsafe StringBuilder Append(string? value, int startIndex, int count)
StringBuilder AppendFormatHelper(IFormatProvider provider, string format, ParamsArray args)
StringBuilder Append(ushort value)
override string ToString()
unsafe void InternalCopy(IntPtr dest, int charLen)
Span< char > RemainingCurrentChunk
void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
unsafe StringBuilder Insert(int index, char value)
StringBuilder Append(char value, int repeatCount)
StringBuilder AppendFormat(string format, object? arg0)
StringBuilder Replace(char oldChar, char newChar, int startIndex, int count)
StringBuilder AppendFormat(IFormatProvider? provider, string format, object? arg0)
StringBuilder Append(IFormatProvider? provider, [InterpolatedStringHandlerArgument(new string[] { "", "provider" })] ref AppendInterpolatedStringHandler handler)
StringBuilder Replace(string oldValue, string? newValue)
StringBuilder(int size, int maxCapacity, StringBuilder previousBlock)
unsafe StringBuilder Insert(int index, char[]? value, int startIndex, int charCount)
StringBuilder Append(char value)
unsafe StringBuilder AppendJoinCore< T >(char *separator, int separatorLength, IEnumerable< T > values)
unsafe StringBuilder Append(char *value, int valueCount)
unsafe void ReplaceBufferInternal(char *newBuffer, int newLength)
unsafe StringBuilder Append(char[]? value)
StringBuilder Append(sbyte value)
void MakeRoom(int index, int count, out StringBuilder chunk, out int indexInChunk, bool doNotMoveFollowingChars)
StringBuilder Append(float value)
StringBuilder Append([InterpolatedStringHandlerArgument("")] ref AppendInterpolatedStringHandler handler)
static void ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen()
static void ThrowArgumentNullException(string name)
object? GetFormat(Type? formatType)
void GetObjectData(SerializationInfo info, StreamingContext context)
int Length
Definition Span.cs:70
void AppendFormatted(object? value, int alignment=0, string? format=null)
AppendInterpolatedStringHandler(int literalLength, int formattedCount, StringBuilder stringBuilder)
AppendInterpolatedStringHandler(int literalLength, int formattedCount, StringBuilder stringBuilder, IFormatProvider? provider)
void AppendFormatted(ReadOnlySpan< char > value, int alignment=0, string? format=null)
void AppendFormattedWithTempSpace< T >(T value, int alignment, string format)
void AppendFormatted(string? value, int alignment=0, string? format=null)
static int ChunkCount(StringBuilder stringBuilder)
ChunkEnumerator(StringBuilder stringBuilder)