Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MemoryExtensions.cs
Go to the documentation of this file.
6using System.Text;
8
9namespace System;
10
11public static class MemoryExtensions
12{
16 {
17 private readonly Span<char> _destination;
18
19 private readonly IFormatProvider _provider;
20
21 internal int _pos;
22
23 internal bool _success;
24
25 private readonly bool _hasCustomFormatter;
26
35
44
45 [MethodImpl(MethodImplOptions.AggressiveInlining)]
46 public bool AppendLiteral(string value)
47 {
48 if (value.Length == 1)
49 {
51 int pos = _pos;
52 if ((uint)pos < (uint)destination.Length)
53 {
54 destination[pos] = value[0];
55 _pos = pos + 1;
56 return true;
57 }
58 return Fail();
59 }
60 if (value.Length == 2)
61 {
63 int pos2 = _pos;
64 if ((uint)pos2 < destination2.Length - 1)
65 {
66 Unsafe.WriteUnaligned(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(destination2), pos2)), Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref value.GetRawStringData())));
67 _pos = pos2 + 2;
68 return true;
69 }
70 return Fail();
71 }
73 }
74
75 private bool AppendStringDirect(string value)
76 {
77 if (value.TryCopyTo(_destination.Slice(_pos)))
78 {
79 _pos += value.Length;
80 return true;
81 }
82 return Fail();
83 }
84
86 {
88 {
89 return AppendCustomFormatter(value, null);
90 }
91 string text;
93 {
95 {
97 {
99 return true;
100 }
101 return Fail();
102 }
103 text = ((IFormattable)(object)value).ToString(null, _provider);
104 }
105 else
106 {
107 text = value?.ToString();
108 }
109 if (text != null)
110 {
111 return AppendStringDirect(text);
112 }
113 return true;
114 }
115
116 public bool AppendFormatted<T>(T value, string? format)
117 {
119 {
121 }
122 string text;
124 {
126 {
128 {
130 return true;
131 }
132 return Fail();
133 }
135 }
136 else
137 {
138 text = value?.ToString();
139 }
140 if (text != null)
141 {
142 return AppendStringDirect(text);
143 }
144 return true;
145 }
146
148 {
149 int pos = _pos;
151 {
152 if (alignment != 0)
153 {
155 }
156 return true;
157 }
158 return Fail();
159 }
160
161 public bool AppendFormatted<T>(T value, int alignment, string? format)
162 {
163 int pos = _pos;
165 {
166 if (alignment != 0)
167 {
169 }
170 return true;
171 }
172 return Fail();
173 }
174
176 {
177 if (value.TryCopyTo(_destination.Slice(_pos)))
178 {
179 _pos += value.Length;
180 return true;
181 }
182 return Fail();
183 }
184
185 public bool AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string? format = null)
186 {
187 bool flag = false;
188 if (alignment < 0)
189 {
190 flag = true;
192 }
193 int num = alignment - value.Length;
194 if (num <= 0)
195 {
196 return AppendFormatted(value);
197 }
199 {
200 if (flag)
201 {
202 value.CopyTo(_destination.Slice(_pos));
203 _pos += value.Length;
204 _destination.Slice(_pos, num).Fill(' ');
205 _pos += num;
206 }
207 else
208 {
209 _destination.Slice(_pos, num).Fill(' ');
210 _pos += num;
211 value.CopyTo(_destination.Slice(_pos));
212 _pos += value.Length;
213 }
214 return true;
215 }
216 return Fail();
217 }
218
219 public bool AppendFormatted(string? value)
220 {
222 {
223 return AppendCustomFormatter(value, null);
224 }
225 if (value == null)
226 {
227 return true;
228 }
229 if (value.TryCopyTo(_destination.Slice(_pos)))
230 {
231 _pos += value.Length;
232 return true;
233 }
234 return Fail();
235 }
236
237 public bool AppendFormatted(string? value, int alignment = 0, string? format = null)
238 {
240 }
241
242 public bool AppendFormatted(object? value, int alignment = 0, string? format = null)
243 {
245 }
246
247 [MethodImpl(MethodImplOptions.NoInlining)]
248 private bool AppendCustomFormatter<T>(T value, string format)
249 {
251 if (customFormatter != null)
252 {
253 string text = customFormatter.Format(format, value, _provider);
254 if (text != null)
255 {
256 return AppendStringDirect(text);
257 }
258 }
259 return true;
260 }
261
263 {
264 int num = _pos - startingPos;
265 bool flag = false;
266 if (alignment < 0)
267 {
268 flag = true;
270 }
271 int num2 = alignment - num;
272 if (num2 <= 0)
273 {
274 return true;
275 }
276 if (num2 <= _destination.Length - _pos)
277 {
278 if (flag)
279 {
280 _destination.Slice(_pos, num2).Fill(' ');
281 }
282 else
283 {
286 }
287 _pos += num2;
288 return true;
289 }
290 return Fail();
291 }
292
293 private bool Fail()
294 {
295 _success = false;
296 return false;
297 }
298 }
299
300 [MethodImpl(MethodImplOptions.AggressiveInlining)]
301 public static Span<T> AsSpan<T>(this T[]? array, int start)
302 {
303 if (array == null)
304 {
305 if (start != 0)
306 {
308 }
309 return default(Span<T>);
310 }
311 if (!typeof(T).IsValueType && array.GetType() != typeof(T[]))
312 {
314 }
315 if ((uint)start > (uint)array.Length)
316 {
318 }
319 return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)start), array.Length - start);
320 }
321
322 [MethodImpl(MethodImplOptions.AggressiveInlining)]
323 public static Span<T> AsSpan<T>(this T[]? array, Index startIndex)
324 {
325 if (array == null)
326 {
327 if (!startIndex.Equals(Index.Start))
328 {
330 }
331 return default(Span<T>);
332 }
333 if (!typeof(T).IsValueType && array.GetType() != typeof(T[]))
334 {
336 }
337 int offset = startIndex.GetOffset(array.Length);
338 if ((uint)offset > (uint)array.Length)
339 {
341 }
342 return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)offset), array.Length - offset);
343 }
344
345 [MethodImpl(MethodImplOptions.AggressiveInlining)]
346 public static Span<T> AsSpan<T>(this T[]? array, Range range)
347 {
348 if (array == null)
349 {
350 Index start = range.Start;
351 Index end = range.End;
352 if (!start.Equals(Index.Start) || !end.Equals(Index.Start))
353 {
355 }
356 return default(Span<T>);
357 }
358 if (!typeof(T).IsValueType && array.GetType() != typeof(T[]))
359 {
361 }
362 var (num, length) = range.GetOffsetAndLength(array.Length);
363 return new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)num), length);
364 }
365
366 [MethodImpl(MethodImplOptions.AggressiveInlining)]
367 public static ReadOnlySpan<char> AsSpan(this string? text)
368 {
369 if (text == null)
370 {
371 return default(ReadOnlySpan<char>);
372 }
373 return new ReadOnlySpan<char>(ref text.GetRawStringData(), text.Length);
374 }
375
376 [MethodImpl(MethodImplOptions.AggressiveInlining)]
377 public static ReadOnlySpan<char> AsSpan(this string? text, int start)
378 {
379 if (text == null)
380 {
381 if (start != 0)
382 {
384 }
385 return default(ReadOnlySpan<char>);
386 }
387 if ((uint)start > (uint)text.Length)
388 {
390 }
391 return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetRawStringData(), (nint)(uint)start), text.Length - start);
392 }
393
394 [MethodImpl(MethodImplOptions.AggressiveInlining)]
395 public static ReadOnlySpan<char> AsSpan(this string? text, int start, int length)
396 {
397 if (text == null)
398 {
399 if (start != 0 || length != 0)
400 {
402 }
403 return default(ReadOnlySpan<char>);
404 }
405 if ((ulong)((long)(uint)start + (long)(uint)length) > (ulong)(uint)text.Length)
406 {
408 }
409 return new ReadOnlySpan<char>(ref Unsafe.Add(ref text.GetRawStringData(), (nint)(uint)start), length);
410 }
411
412 public static ReadOnlyMemory<char> AsMemory(this string? text)
413 {
414 if (text == null)
415 {
416 return default(ReadOnlyMemory<char>);
417 }
418 return new ReadOnlyMemory<char>(text, 0, text.Length);
419 }
420
421 public static ReadOnlyMemory<char> AsMemory(this string? text, int start)
422 {
423 if (text == null)
424 {
425 if (start != 0)
426 {
428 }
429 return default(ReadOnlyMemory<char>);
430 }
431 if ((uint)start > (uint)text.Length)
432 {
434 }
435 return new ReadOnlyMemory<char>(text, start, text.Length - start);
436 }
437
438 public static ReadOnlyMemory<char> AsMemory(this string? text, Index startIndex)
439 {
440 if (text == null)
441 {
442 if (!startIndex.Equals(Index.Start))
443 {
445 }
446 return default(ReadOnlyMemory<char>);
447 }
448 int offset = startIndex.GetOffset(text.Length);
449 if ((uint)offset > (uint)text.Length)
450 {
452 }
453 return new ReadOnlyMemory<char>(text, offset, text.Length - offset);
454 }
455
456 public static ReadOnlyMemory<char> AsMemory(this string? text, int start, int length)
457 {
458 if (text == null)
459 {
460 if (start != 0 || length != 0)
461 {
463 }
464 return default(ReadOnlyMemory<char>);
465 }
466 if ((ulong)((long)(uint)start + (long)(uint)length) > (ulong)(uint)text.Length)
467 {
469 }
471 }
472
473 public static ReadOnlyMemory<char> AsMemory(this string? text, Range range)
474 {
475 if (text == null)
476 {
477 Index start = range.Start;
478 Index end = range.End;
479 if (!start.Equals(Index.Start) || !end.Equals(Index.Start))
480 {
482 }
483 return default(ReadOnlyMemory<char>);
484 }
485 var (start2, length) = range.GetOffsetAndLength(text.Length);
487 }
488
489 [MethodImpl(MethodImplOptions.AggressiveInlining)]
490 public static bool Contains<T>(this Span<T> span, T value) where T : IEquatable<T>
491 {
492 if (RuntimeHelpers.IsBitwiseEquatable<T>())
493 {
494 if (Unsafe.SizeOf<T>() == 1)
495 {
496 return SpanHelpers.Contains(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length);
497 }
498 if (Unsafe.SizeOf<T>() == 2)
499 {
500 return SpanHelpers.Contains(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length);
501 }
502 }
503 return SpanHelpers.Contains(ref MemoryMarshal.GetReference(span), value, span.Length);
504 }
505
506 [MethodImpl(MethodImplOptions.AggressiveInlining)]
508 {
509 if (RuntimeHelpers.IsBitwiseEquatable<T>())
510 {
511 if (Unsafe.SizeOf<T>() == 1)
512 {
513 return SpanHelpers.Contains(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length);
514 }
515 if (Unsafe.SizeOf<T>() == 2)
516 {
517 return SpanHelpers.Contains(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length);
518 }
519 }
520 return SpanHelpers.Contains(ref MemoryMarshal.GetReference(span), value, span.Length);
521 }
522
523 [MethodImpl(MethodImplOptions.AggressiveInlining)]
524 public static int IndexOf<T>(this Span<T> span, T value) where T : IEquatable<T>
525 {
526 if (RuntimeHelpers.IsBitwiseEquatable<T>())
527 {
528 if (Unsafe.SizeOf<T>() == 1)
529 {
530 return SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length);
531 }
532 if (Unsafe.SizeOf<T>() == 2)
533 {
534 return SpanHelpers.IndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length);
535 }
536 }
537 return SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), value, span.Length);
538 }
539
540 [MethodImpl(MethodImplOptions.AggressiveInlining)]
542 {
543 if (RuntimeHelpers.IsBitwiseEquatable<T>())
544 {
545 if (Unsafe.SizeOf<T>() == 1)
546 {
547 return SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length);
548 }
549 if (Unsafe.SizeOf<T>() == 2)
550 {
551 return SpanHelpers.IndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(value)), value.Length);
552 }
553 }
554 return SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
555 }
556
557 [MethodImpl(MethodImplOptions.AggressiveInlining)]
558 public static int LastIndexOf<T>(this Span<T> span, T value) where T : IEquatable<T>
559 {
560 if (RuntimeHelpers.IsBitwiseEquatable<T>())
561 {
562 if (Unsafe.SizeOf<T>() == 1)
563 {
564 return SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length);
565 }
566 if (Unsafe.SizeOf<T>() == 2)
567 {
568 return SpanHelpers.LastIndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length);
569 }
570 }
571 return SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), value, span.Length);
572 }
573
574 [MethodImpl(MethodImplOptions.AggressiveInlining)]
576 {
577 if (Unsafe.SizeOf<T>() == 1 && RuntimeHelpers.IsBitwiseEquatable<T>())
578 {
579 return SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length);
580 }
581 return SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
582 }
583
584 [MethodImpl(MethodImplOptions.AggressiveInlining)]
586 {
587 int length = span.Length;
588 if (RuntimeHelpers.IsBitwiseEquatable<T>())
589 {
590 nuint num = (nuint)Unsafe.SizeOf<T>();
591 if (length == other.Length)
592 {
593 return SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), (uint)length * num);
594 }
595 return false;
596 }
597 if (length == other.Length)
598 {
599 return SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other), length);
600 }
601 return false;
602 }
603
605 {
606 if (typeof(T) == typeof(byte))
607 {
608 return SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), other.Length);
609 }
610 if (typeof(T) == typeof(char))
611 {
612 return SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(other)), other.Length);
613 }
614 return SpanHelpers.SequenceCompareTo(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(other), other.Length);
615 }
616
617 [MethodImpl(MethodImplOptions.AggressiveInlining)]
619 {
620 if (RuntimeHelpers.IsBitwiseEquatable<T>())
621 {
622 if (Unsafe.SizeOf<T>() == 1)
623 {
624 return SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length);
625 }
626 if (Unsafe.SizeOf<T>() == 2)
627 {
628 return SpanHelpers.IndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length);
629 }
630 }
631 return SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), value, span.Length);
632 }
633
634 [MethodImpl(MethodImplOptions.AggressiveInlining)]
636 {
637 if (RuntimeHelpers.IsBitwiseEquatable<T>())
638 {
639 if (Unsafe.SizeOf<T>() == 1)
640 {
641 return SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length);
642 }
643 if (Unsafe.SizeOf<T>() == 2)
644 {
645 return SpanHelpers.IndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(value)), value.Length);
646 }
647 }
648 return SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
649 }
650
651 [MethodImpl(MethodImplOptions.AggressiveInlining)]
653 {
654 if (RuntimeHelpers.IsBitwiseEquatable<T>())
655 {
656 if (Unsafe.SizeOf<T>() == 1)
657 {
658 return SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length);
659 }
660 if (Unsafe.SizeOf<T>() == 2)
661 {
662 return SpanHelpers.LastIndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length);
663 }
664 }
665 return SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), value, span.Length);
666 }
667
668 [MethodImpl(MethodImplOptions.AggressiveInlining)]
670 {
671 if (Unsafe.SizeOf<T>() == 1 && RuntimeHelpers.IsBitwiseEquatable<T>())
672 {
673 return SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length);
674 }
675 return SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
676 }
677
678 [MethodImpl(MethodImplOptions.AggressiveInlining)]
679 public static int IndexOfAny<T>(this Span<T> span, T value0, T value1) where T : IEquatable<T>
680 {
681 if (RuntimeHelpers.IsBitwiseEquatable<T>())
682 {
683 if (Unsafe.SizeOf<T>() == 1)
684 {
685 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length);
686 }
687 if (Unsafe.SizeOf<T>() == 2)
688 {
689 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value0), Unsafe.As<T, char>(ref value1), span.Length);
690 }
691 }
692 return SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length);
693 }
694
695 [MethodImpl(MethodImplOptions.AggressiveInlining)]
696 public static int IndexOfAny<T>(this Span<T> span, T value0, T value1, T value2) where T : IEquatable<T>
697 {
698 if (RuntimeHelpers.IsBitwiseEquatable<T>())
699 {
700 if (Unsafe.SizeOf<T>() == 1)
701 {
702 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length);
703 }
704 if (Unsafe.SizeOf<T>() == 2)
705 {
706 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value0), Unsafe.As<T, char>(ref value1), Unsafe.As<T, char>(ref value2), span.Length);
707 }
708 }
709 return SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length);
710 }
711
712 [MethodImpl(MethodImplOptions.AggressiveInlining)]
714 {
715 return ((ReadOnlySpan<T>)span).IndexOfAny(values);
716 }
717
718 [MethodImpl(MethodImplOptions.AggressiveInlining)]
720 {
721 if (RuntimeHelpers.IsBitwiseEquatable<T>())
722 {
723 if (Unsafe.SizeOf<T>() == 1)
724 {
725 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length);
726 }
727 if (Unsafe.SizeOf<T>() == 2)
728 {
729 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value0), Unsafe.As<T, char>(ref value1), span.Length);
730 }
731 }
732 return SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length);
733 }
734
735 [MethodImpl(MethodImplOptions.AggressiveInlining)]
737 {
738 if (RuntimeHelpers.IsBitwiseEquatable<T>())
739 {
740 if (Unsafe.SizeOf<T>() == 1)
741 {
742 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length);
743 }
744 if (Unsafe.SizeOf<T>() == 2)
745 {
746 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value0), Unsafe.As<T, char>(ref value1), Unsafe.As<T, char>(ref value2), span.Length);
747 }
748 }
749 return SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length);
750 }
751
752 [MethodImpl(MethodImplOptions.AggressiveInlining)]
754 {
755 if (RuntimeHelpers.IsBitwiseEquatable<T>())
756 {
757 if (Unsafe.SizeOf<T>() == 1)
758 {
759 ref byte reference = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values));
760 if (values.Length == 2)
761 {
762 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), reference, Unsafe.Add(ref reference, 1), span.Length);
763 }
764 if (values.Length == 3)
765 {
766 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), reference, Unsafe.Add(ref reference, 1), Unsafe.Add(ref reference, 2), span.Length);
767 }
768 }
769 if (Unsafe.SizeOf<T>() == 2)
770 {
771 ref char reference2 = ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(values));
772 if (values.Length == 5)
773 {
774 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), reference2, Unsafe.Add(ref reference2, 1), Unsafe.Add(ref reference2, 2), Unsafe.Add(ref reference2, 3), Unsafe.Add(ref reference2, 4), span.Length);
775 }
776 if (values.Length == 2)
777 {
778 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), reference2, Unsafe.Add(ref reference2, 1), span.Length);
779 }
780 if (values.Length == 4)
781 {
782 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), reference2, Unsafe.Add(ref reference2, 1), Unsafe.Add(ref reference2, 2), Unsafe.Add(ref reference2, 3), span.Length);
783 }
784 if (values.Length == 3)
785 {
786 return SpanHelpers.IndexOfAny(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), reference2, Unsafe.Add(ref reference2, 1), Unsafe.Add(ref reference2, 2), span.Length);
787 }
788 if (values.Length == 1)
789 {
790 return SpanHelpers.IndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), reference2, span.Length);
791 }
792 }
793 }
794 return SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length);
795 }
796
797 [MethodImpl(MethodImplOptions.AggressiveInlining)]
799 {
800 if (Unsafe.SizeOf<T>() == 1 && RuntimeHelpers.IsBitwiseEquatable<T>())
801 {
802 return SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length);
803 }
804 return SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length);
805 }
806
807 [MethodImpl(MethodImplOptions.AggressiveInlining)]
809 {
810 if (Unsafe.SizeOf<T>() == 1 && RuntimeHelpers.IsBitwiseEquatable<T>())
811 {
812 return SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length);
813 }
814 return SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length);
815 }
816
817 [MethodImpl(MethodImplOptions.AggressiveInlining)]
819 {
820 if (Unsafe.SizeOf<T>() == 1 && RuntimeHelpers.IsBitwiseEquatable<T>())
821 {
822 return SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)), values.Length);
823 }
824 return SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length);
825 }
826
827 [MethodImpl(MethodImplOptions.AggressiveInlining)]
829 {
830 if (Unsafe.SizeOf<T>() == 1 && RuntimeHelpers.IsBitwiseEquatable<T>())
831 {
832 return SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length);
833 }
834 return SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length);
835 }
836
837 [MethodImpl(MethodImplOptions.AggressiveInlining)]
839 {
840 if (Unsafe.SizeOf<T>() == 1 && RuntimeHelpers.IsBitwiseEquatable<T>())
841 {
842 return SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length);
843 }
844 return SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length);
845 }
846
847 [MethodImpl(MethodImplOptions.AggressiveInlining)]
849 {
850 return SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length);
851 }
852
853 [MethodImpl(MethodImplOptions.AggressiveInlining)]
855 {
856 int length = span.Length;
857 if (RuntimeHelpers.IsBitwiseEquatable<T>())
858 {
859 nuint num = (nuint)Unsafe.SizeOf<T>();
860 if (length == other.Length)
861 {
862 return SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), (uint)length * num);
863 }
864 return false;
865 }
866 if (length == other.Length)
867 {
868 return SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other), length);
869 }
870 return false;
871 }
872
874 {
875 return ((ReadOnlySpan<T>)span).SequenceEqual(other, comparer);
876 }
877
879 {
880 if (span.Length != other.Length)
881 {
882 return false;
883 }
884 if (typeof(T).IsValueType && (comparer == null || comparer == EqualityComparer<T>.Default))
885 {
886 if (RuntimeHelpers.IsBitwiseEquatable<T>())
887 {
888 nuint num = (nuint)Unsafe.SizeOf<T>();
889 return SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), (uint)span.Length * num);
890 }
891 for (int i = 0; i < span.Length; i++)
892 {
893 if (!EqualityComparer<T>.Default.Equals(span[i], other[i]))
894 {
895 return false;
896 }
897 }
898 return true;
899 }
900 if (comparer == null)
901 {
903 }
904 for (int j = 0; j < span.Length; j++)
905 {
906 if (!comparer.Equals(span[j], other[j]))
907 {
908 return false;
909 }
910 }
911 return true;
912 }
913
914 [MethodImpl(MethodImplOptions.AggressiveInlining)]
916 {
917 if (typeof(T) == typeof(byte))
918 {
919 return SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), other.Length);
920 }
921 if (typeof(T) == typeof(char))
922 {
923 return SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(other)), other.Length);
924 }
925 return SpanHelpers.SequenceCompareTo(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(other), other.Length);
926 }
927
928 [MethodImpl(MethodImplOptions.AggressiveInlining)]
930 {
931 int length = value.Length;
932 if (RuntimeHelpers.IsBitwiseEquatable<T>())
933 {
934 nuint num = (nuint)Unsafe.SizeOf<T>();
935 if (length <= span.Length)
936 {
937 return SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (uint)length * num);
938 }
939 return false;
940 }
941 if (length <= span.Length)
942 {
943 return SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), length);
944 }
945 return false;
946 }
947
948 [MethodImpl(MethodImplOptions.AggressiveInlining)]
950 {
951 int length = value.Length;
952 if (RuntimeHelpers.IsBitwiseEquatable<T>())
953 {
954 nuint num = (nuint)Unsafe.SizeOf<T>();
955 if (length <= span.Length)
956 {
957 return SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (uint)length * num);
958 }
959 return false;
960 }
961 if (length <= span.Length)
962 {
963 return SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), length);
964 }
965 return false;
966 }
967
968 [MethodImpl(MethodImplOptions.AggressiveInlining)]
970 {
971 int length = span.Length;
972 int length2 = value.Length;
973 if (RuntimeHelpers.IsBitwiseEquatable<T>())
974 {
975 nuint num = (nuint)Unsafe.SizeOf<T>();
976 if (length2 <= length)
977 {
978 return SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)(length - length2))), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (uint)length2 * num);
979 }
980 return false;
981 }
982 if (length2 <= length)
983 {
984 return SpanHelpers.SequenceEqual(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)(length - length2)), ref MemoryMarshal.GetReference(value), length2);
985 }
986 return false;
987 }
988
989 [MethodImpl(MethodImplOptions.AggressiveInlining)]
991 {
992 int length = span.Length;
993 int length2 = value.Length;
994 if (RuntimeHelpers.IsBitwiseEquatable<T>())
995 {
996 nuint num = (nuint)Unsafe.SizeOf<T>();
997 if (length2 <= length)
998 {
999 return SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)(length - length2))), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (uint)length2 * num);
1000 }
1001 return false;
1002 }
1003 if (length2 <= length)
1004 {
1005 return SpanHelpers.SequenceEqual(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)(length - length2)), ref MemoryMarshal.GetReference(value), length2);
1006 }
1007 return false;
1008 }
1009
1010 public static void Reverse<T>(this Span<T> span)
1011 {
1012 if (span.Length > 1)
1013 {
1014 ref T reference = ref MemoryMarshal.GetReference(span);
1015 ref T reference2 = ref Unsafe.Add(ref Unsafe.Add(ref reference, span.Length), -1);
1016 do
1017 {
1018 T val = reference;
1020 reference2 = val;
1021 reference = ref Unsafe.Add(ref reference, 1);
1022 reference2 = ref Unsafe.Add(ref reference2, -1);
1023 }
1024 while (Unsafe.IsAddressLessThan(ref reference, ref reference2));
1025 }
1026 }
1027
1028 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1029 public static Span<T> AsSpan<T>(this T[]? array)
1030 {
1031 return new Span<T>(array);
1032 }
1033
1034 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1035 public static Span<T> AsSpan<T>(this T[]? array, int start, int length)
1036 {
1037 return new Span<T>(array, start, length);
1038 }
1039
1040 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1042 {
1043 return new Span<T>(segment.Array, segment.Offset, segment.Count);
1044 }
1045
1046 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1048 {
1049 if ((uint)start > (uint)segment.Count)
1050 {
1052 }
1053 return new Span<T>(segment.Array, segment.Offset + start, segment.Count - start);
1054 }
1055
1056 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1058 {
1059 int offset = startIndex.GetOffset(segment.Count);
1060 return segment.AsSpan(offset);
1061 }
1062
1063 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1064 public static Span<T> AsSpan<T>(this ArraySegment<T> segment, int start, int length)
1065 {
1066 if ((uint)start > (uint)segment.Count)
1067 {
1069 }
1070 if ((uint)length > (uint)(segment.Count - start))
1071 {
1073 }
1074 return new Span<T>(segment.Array, segment.Offset + start, length);
1075 }
1076
1077 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1079 {
1080 var (num, length) = range.GetOffsetAndLength(segment.Count);
1081 return new Span<T>(segment.Array, segment.Offset + num, length);
1082 }
1083
1084 public static Memory<T> AsMemory<T>(this T[]? array)
1085 {
1086 return new Memory<T>(array);
1087 }
1088
1089 public static Memory<T> AsMemory<T>(this T[]? array, int start)
1090 {
1091 return new Memory<T>(array, start);
1092 }
1093
1094 public static Memory<T> AsMemory<T>(this T[]? array, Index startIndex)
1095 {
1096 if (array == null)
1097 {
1098 if (!startIndex.Equals(Index.Start))
1099 {
1101 }
1102 return default(Memory<T>);
1103 }
1104 int offset = startIndex.GetOffset(array.Length);
1105 return new Memory<T>(array, offset);
1106 }
1107
1108 public static Memory<T> AsMemory<T>(this T[]? array, int start, int length)
1109 {
1110 return new Memory<T>(array, start, length);
1111 }
1112
1113 public static Memory<T> AsMemory<T>(this T[]? array, Range range)
1114 {
1115 if (array == null)
1116 {
1117 Index start = range.Start;
1118 Index end = range.End;
1119 if (!start.Equals(Index.Start) || !end.Equals(Index.Start))
1120 {
1122 }
1123 return default(Memory<T>);
1124 }
1125 var (start2, length) = range.GetOffsetAndLength(array.Length);
1126 return new Memory<T>(array, start2, length);
1127 }
1128
1130 {
1131 return new Memory<T>(segment.Array, segment.Offset, segment.Count);
1132 }
1133
1135 {
1136 if ((uint)start > (uint)segment.Count)
1137 {
1139 }
1140 return new Memory<T>(segment.Array, segment.Offset + start, segment.Count - start);
1141 }
1142
1144 {
1145 if ((uint)start > (uint)segment.Count)
1146 {
1148 }
1149 if ((uint)length > (uint)(segment.Count - start))
1150 {
1152 }
1153 return new Memory<T>(segment.Array, segment.Offset + start, length);
1154 }
1155
1156 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1157 public static void CopyTo<T>(this T[]? source, Span<T> destination)
1158 {
1160 }
1161
1162 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1163 public static void CopyTo<T>(this T[]? source, Memory<T> destination)
1164 {
1165 source.CopyTo(destination.Span);
1166 }
1167
1168 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1170 {
1171 return ((ReadOnlySpan<T>)span).Overlaps(other);
1172 }
1173
1174 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1176 {
1177 return ((ReadOnlySpan<T>)span).Overlaps(other, out elementOffset);
1178 }
1179
1181 {
1182 if (span.IsEmpty || other.IsEmpty)
1183 {
1184 return false;
1185 }
1186 IntPtr intPtr = Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other));
1187 if (Unsafe.SizeOf<IntPtr>() == 4)
1188 {
1189 if ((uint)(int)intPtr >= (uint)(span.Length * Unsafe.SizeOf<T>()))
1190 {
1191 return (uint)(int)intPtr > (uint)(-(other.Length * Unsafe.SizeOf<T>()));
1192 }
1193 return true;
1194 }
1195 if ((ulong)(long)intPtr >= (ulong)((long)span.Length * (long)Unsafe.SizeOf<T>()))
1196 {
1197 return (ulong)(long)intPtr > (ulong)(-((long)other.Length * (long)Unsafe.SizeOf<T>()));
1198 }
1199 return true;
1200 }
1201
1203 {
1204 if (span.IsEmpty || other.IsEmpty)
1205 {
1206 elementOffset = 0;
1207 return false;
1208 }
1209 IntPtr intPtr = Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other));
1210 if (Unsafe.SizeOf<IntPtr>() == 4)
1211 {
1212 if ((uint)(int)intPtr < (uint)(span.Length * Unsafe.SizeOf<T>()) || (uint)(int)intPtr > (uint)(-(other.Length * Unsafe.SizeOf<T>())))
1213 {
1214 if ((int)intPtr % Unsafe.SizeOf<T>() != 0)
1215 {
1217 }
1218 elementOffset = (int)intPtr / Unsafe.SizeOf<T>();
1219 return true;
1220 }
1221 elementOffset = 0;
1222 return false;
1223 }
1224 if ((ulong)(long)intPtr < (ulong)((long)span.Length * (long)Unsafe.SizeOf<T>()) || (ulong)(long)intPtr > (ulong)(-((long)other.Length * (long)Unsafe.SizeOf<T>())))
1225 {
1226 if ((long)intPtr % Unsafe.SizeOf<T>() != 0L)
1227 {
1229 }
1230 elementOffset = (int)((long)intPtr / Unsafe.SizeOf<T>());
1231 return true;
1232 }
1233 elementOffset = 0;
1234 return false;
1235 }
1236
1237 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1239 {
1240 return span.BinarySearch<T, IComparable<T>>(comparable);
1241 }
1242
1243 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1248
1249 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1251 {
1252 return ((ReadOnlySpan<T>)span).BinarySearch(value, comparer);
1253 }
1254
1255 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1257 {
1258 return MemoryExtensions.BinarySearch<T, IComparable<T>>(span, comparable);
1259 }
1260
1261 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1266
1267 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1277
1278 public static void Sort<T>(this Span<T> span)
1279 {
1280 span.Sort((IComparer<T>)null);
1281 }
1282
1284 {
1285 if (span.Length > 1)
1286 {
1287 ArraySortHelper<T>.Default.Sort(span, comparer);
1288 }
1289 }
1290
1291 public static void Sort<T>(this Span<T> span, Comparison<T> comparison)
1292 {
1293 if (comparison == null)
1294 {
1296 }
1297 if (span.Length > 1)
1298 {
1300 }
1301 }
1302
1303 public static void Sort<TKey, TValue>(this Span<TKey> keys, Span<TValue> items)
1304 {
1305 keys.Sort<TKey, TValue, IComparer<TKey>>(items, null);
1306 }
1307
1309 {
1310 if (keys.Length != items.Length)
1311 {
1312 ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_SpansMustHaveSameLength);
1313 }
1314 if (keys.Length > 1)
1315 {
1316 ArraySortHelper<TKey, TValue>.Default.Sort(keys, items, comparer);
1317 }
1318 }
1319
1321 {
1322 if (comparison == null)
1323 {
1325 }
1326 if (keys.Length != items.Length)
1327 {
1328 ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_SpansMustHaveSameLength);
1329 }
1330 if (keys.Length > 1)
1331 {
1333 }
1334 }
1335
1337 {
1338 if (handler._success)
1339 {
1340 charsWritten = handler._pos;
1341 return true;
1342 }
1343 charsWritten = 0;
1344 return false;
1345 }
1346
1347 public static bool TryWrite(this Span<char> destination, IFormatProvider? provider, [InterpolatedStringHandlerArgument(new string[] { "destination", "provider" })] ref TryWriteInterpolatedStringHandler handler, out int charsWritten)
1348 {
1349 return destination.TryWrite(ref handler, out charsWritten);
1350 }
1351
1352 public static bool IsWhiteSpace(this ReadOnlySpan<char> span)
1353 {
1354 for (int i = 0; i < span.Length; i++)
1355 {
1356 if (!char.IsWhiteSpace(span[i]))
1357 {
1358 return false;
1359 }
1360 }
1361 return true;
1362 }
1363
1365 {
1366 return span.IndexOf(value, comparisonType) >= 0;
1367 }
1368
1370 {
1371 string.CheckStringComparison(comparisonType);
1372 switch (comparisonType)
1373 {
1374 case StringComparison.CurrentCulture:
1375 case StringComparison.CurrentCultureIgnoreCase:
1376 return CultureInfo.CurrentCulture.CompareInfo.Compare(span, other, string.GetCaseCompareOfComparisonCulture(comparisonType)) == 0;
1377 case StringComparison.InvariantCulture:
1378 case StringComparison.InvariantCultureIgnoreCase:
1379 return CompareInfo.Invariant.Compare(span, other, string.GetCaseCompareOfComparisonCulture(comparisonType)) == 0;
1380 case StringComparison.Ordinal:
1381 return span.EqualsOrdinal(other);
1382 default:
1383 return span.EqualsOrdinalIgnoreCase(other);
1384 }
1385 }
1386
1387 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1389 {
1390 if (span.Length != value.Length)
1391 {
1392 return false;
1393 }
1394 if (value.Length == 0)
1395 {
1396 return true;
1397 }
1398 return span.SequenceEqual(value);
1399 }
1400
1401 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1403 {
1404 if (span.Length != value.Length)
1405 {
1406 return false;
1407 }
1408 if (value.Length == 0)
1409 {
1410 return true;
1411 }
1412 return Ordinal.EqualsIgnoreCase(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), span.Length);
1413 }
1414
1416 {
1417 string.CheckStringComparison(comparisonType);
1418 switch (comparisonType)
1419 {
1420 case StringComparison.CurrentCulture:
1421 case StringComparison.CurrentCultureIgnoreCase:
1422 return CultureInfo.CurrentCulture.CompareInfo.Compare(span, other, string.GetCaseCompareOfComparisonCulture(comparisonType));
1423 case StringComparison.InvariantCulture:
1424 case StringComparison.InvariantCultureIgnoreCase:
1425 return CompareInfo.Invariant.Compare(span, other, string.GetCaseCompareOfComparisonCulture(comparisonType));
1426 case StringComparison.Ordinal:
1427 if (span.Length == 0 || other.Length == 0)
1428 {
1429 return span.Length - other.Length;
1430 }
1431 return string.CompareOrdinal(span, other);
1432 default:
1433 return Ordinal.CompareStringIgnoreCase(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(other), other.Length);
1434 }
1435 }
1436
1438 {
1439 string.CheckStringComparison(comparisonType);
1440 switch (comparisonType)
1441 {
1442 case StringComparison.Ordinal:
1443 return SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
1444 case StringComparison.CurrentCulture:
1445 case StringComparison.CurrentCultureIgnoreCase:
1446 return CultureInfo.CurrentCulture.CompareInfo.IndexOf(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType));
1447 case StringComparison.InvariantCulture:
1448 case StringComparison.InvariantCultureIgnoreCase:
1449 return CompareInfo.Invariant.IndexOf(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType));
1450 default:
1452 }
1453 }
1454
1456 {
1457 string.CheckStringComparison(comparisonType);
1458 switch (comparisonType)
1459 {
1460 case StringComparison.Ordinal:
1461 return SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
1462 case StringComparison.CurrentCulture:
1463 case StringComparison.CurrentCultureIgnoreCase:
1464 return CultureInfo.CurrentCulture.CompareInfo.LastIndexOf(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType));
1465 case StringComparison.InvariantCulture:
1466 case StringComparison.InvariantCultureIgnoreCase:
1467 return CompareInfo.Invariant.LastIndexOf(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType));
1468 default:
1470 }
1471 }
1472
1474 {
1475 if (source.Overlaps(destination))
1476 {
1478 }
1479 if (culture == null)
1480 {
1482 }
1483 if (destination.Length < source.Length)
1484 {
1485 return -1;
1486 }
1488 {
1490 }
1491 else
1492 {
1493 culture.TextInfo.ChangeCaseToLower(source, destination);
1494 }
1495 return source.Length;
1496 }
1497
1499 {
1500 if (source.Overlaps(destination))
1501 {
1503 }
1504 if (destination.Length < source.Length)
1505 {
1506 return -1;
1507 }
1509 {
1511 }
1512 else
1513 {
1514 TextInfo.Invariant.ChangeCaseToLower(source, destination);
1515 }
1516 return source.Length;
1517 }
1518
1520 {
1521 if (source.Overlaps(destination))
1522 {
1524 }
1525 if (culture == null)
1526 {
1528 }
1529 if (destination.Length < source.Length)
1530 {
1531 return -1;
1532 }
1534 {
1536 }
1537 else
1538 {
1539 culture.TextInfo.ChangeCaseToUpper(source, destination);
1540 }
1541 return source.Length;
1542 }
1543
1545 {
1546 if (source.Overlaps(destination))
1547 {
1549 }
1550 if (destination.Length < source.Length)
1551 {
1552 return -1;
1553 }
1555 {
1557 }
1558 else
1559 {
1560 TextInfo.Invariant.ChangeCaseToUpper(source, destination);
1561 }
1562 return source.Length;
1563 }
1564
1566 {
1567 string.CheckStringComparison(comparisonType);
1568 switch (comparisonType)
1569 {
1570 case StringComparison.CurrentCulture:
1571 case StringComparison.CurrentCultureIgnoreCase:
1572 return CultureInfo.CurrentCulture.CompareInfo.IsSuffix(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType));
1573 case StringComparison.InvariantCulture:
1574 case StringComparison.InvariantCultureIgnoreCase:
1575 return CompareInfo.Invariant.IsSuffix(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType));
1576 case StringComparison.Ordinal:
1577 return span.EndsWith(value);
1578 default:
1579 return span.EndsWithOrdinalIgnoreCase(value);
1580 }
1581 }
1582
1583 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1585 {
1586 if (value.Length <= span.Length)
1587 {
1588 return Ordinal.EqualsIgnoreCase(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), span.Length - value.Length), ref MemoryMarshal.GetReference(value), value.Length);
1589 }
1590 return false;
1591 }
1592
1594 {
1595 string.CheckStringComparison(comparisonType);
1596 switch (comparisonType)
1597 {
1598 case StringComparison.CurrentCulture:
1599 case StringComparison.CurrentCultureIgnoreCase:
1600 return CultureInfo.CurrentCulture.CompareInfo.IsPrefix(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType));
1601 case StringComparison.InvariantCulture:
1602 case StringComparison.InvariantCultureIgnoreCase:
1603 return CompareInfo.Invariant.IsPrefix(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType));
1604 case StringComparison.Ordinal:
1605 return span.StartsWith(value);
1606 default:
1607 return span.StartsWithOrdinalIgnoreCase(value);
1608 }
1609 }
1610
1611 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1613 {
1614 if (value.Length <= span.Length)
1615 {
1616 return Ordinal.EqualsIgnoreCase(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), value.Length);
1617 }
1618 return false;
1619 }
1620
1622 {
1623 return new SpanRuneEnumerator(span);
1624 }
1625
1627 {
1628 return new SpanRuneEnumerator(span);
1629 }
1630
1632 {
1633 return new SpanLineEnumerator(span);
1634 }
1635
1637 {
1638 return new SpanLineEnumerator(span);
1639 }
1640
1642 {
1646 return memory.Slice(start, length);
1647 }
1648
1650 {
1651 return memory.Slice(ClampStart(memory.Span, trimElement));
1652 }
1653
1655 {
1656 return memory.Slice(0, ClampEnd(memory.Span, 0, trimElement));
1657 }
1658
1660 {
1664 return memory.Slice(start, length);
1665 }
1666
1671
1673 {
1674 return memory.Slice(0, ClampEnd(memory.Span, 0, trimElement));
1675 }
1676
1678 {
1681 return span.Slice(start, length);
1682 }
1683
1685 {
1686 return span.Slice(ClampStart(span, trimElement));
1687 }
1688
1690 {
1691 return span.Slice(0, ClampEnd(span, 0, trimElement));
1692 }
1693
1695 {
1698 return span.Slice(start, length);
1699 }
1700
1702 {
1703 return span.Slice(ClampStart(span, trimElement));
1704 }
1705
1707 {
1708 return span.Slice(0, ClampEnd(span, 0, trimElement));
1709 }
1710
1712 {
1713 int i = 0;
1714 if (trimElement != null)
1715 {
1716 for (; i < span.Length && trimElement.Equals(span[i]); i++)
1717 {
1718 }
1719 }
1720 else
1721 {
1722 for (; i < span.Length && span[i] == null; i++)
1723 {
1724 }
1725 }
1726 return i;
1727 }
1728
1730 {
1731 int num = span.Length - 1;
1732 if (trimElement != null)
1733 {
1734 while (num >= start && trimElement.Equals(span[num]))
1735 {
1736 num--;
1737 }
1738 }
1739 else
1740 {
1741 while (num >= start && span[num] == null)
1742 {
1743 num--;
1744 }
1745 }
1746 return num - start + 1;
1747 }
1748
1750 {
1751 if (trimElements.Length > 1)
1752 {
1756 return memory.Slice(start, length);
1757 }
1758 if (trimElements.Length == 1)
1759 {
1760 return memory.Trim(trimElements[0]);
1761 }
1762 return memory;
1763 }
1764
1766 {
1767 if (trimElements.Length > 1)
1768 {
1769 return memory.Slice(ClampStart(memory.Span, trimElements));
1770 }
1771 if (trimElements.Length == 1)
1772 {
1773 return memory.TrimStart(trimElements[0]);
1774 }
1775 return memory;
1776 }
1777
1779 {
1780 if (trimElements.Length > 1)
1781 {
1782 return memory.Slice(0, ClampEnd(memory.Span, 0, trimElements));
1783 }
1784 if (trimElements.Length == 1)
1785 {
1786 return memory.TrimEnd(trimElements[0]);
1787 }
1788 return memory;
1789 }
1790
1792 {
1793 if (trimElements.Length > 1)
1794 {
1798 return memory.Slice(start, length);
1799 }
1800 if (trimElements.Length == 1)
1801 {
1802 return memory.Trim(trimElements[0]);
1803 }
1804 return memory;
1805 }
1806
1808 {
1809 if (trimElements.Length > 1)
1810 {
1811 return memory.Slice(ClampStart(memory.Span, trimElements));
1812 }
1813 if (trimElements.Length == 1)
1814 {
1815 return memory.TrimStart(trimElements[0]);
1816 }
1817 return memory;
1818 }
1819
1821 {
1822 if (trimElements.Length > 1)
1823 {
1824 return memory.Slice(0, ClampEnd(memory.Span, 0, trimElements));
1825 }
1826 if (trimElements.Length == 1)
1827 {
1828 return memory.TrimEnd(trimElements[0]);
1829 }
1830 return memory;
1831 }
1832
1834 {
1835 if (trimElements.Length > 1)
1836 {
1839 return span.Slice(start, length);
1840 }
1841 if (trimElements.Length == 1)
1842 {
1843 return span.Trim(trimElements[0]);
1844 }
1845 return span;
1846 }
1847
1849 {
1850 if (trimElements.Length > 1)
1851 {
1852 return span.Slice(ClampStart(span, trimElements));
1853 }
1854 if (trimElements.Length == 1)
1855 {
1856 return span.TrimStart(trimElements[0]);
1857 }
1858 return span;
1859 }
1860
1862 {
1863 if (trimElements.Length > 1)
1864 {
1865 return span.Slice(0, ClampEnd(span, 0, trimElements));
1866 }
1867 if (trimElements.Length == 1)
1868 {
1869 return span.TrimEnd(trimElements[0]);
1870 }
1871 return span;
1872 }
1873
1875 {
1876 if (trimElements.Length > 1)
1877 {
1880 return span.Slice(start, length);
1881 }
1882 if (trimElements.Length == 1)
1883 {
1884 return span.Trim(trimElements[0]);
1885 }
1886 return span;
1887 }
1888
1890 {
1891 if (trimElements.Length > 1)
1892 {
1893 return span.Slice(ClampStart(span, trimElements));
1894 }
1895 if (trimElements.Length == 1)
1896 {
1897 return span.TrimStart(trimElements[0]);
1898 }
1899 return span;
1900 }
1901
1903 {
1904 if (trimElements.Length > 1)
1905 {
1906 return span.Slice(0, ClampEnd(span, 0, trimElements));
1907 }
1908 if (trimElements.Length == 1)
1909 {
1910 return span.TrimEnd(trimElements[0]);
1911 }
1912 return span;
1913 }
1914
1916 {
1917 int i;
1918 for (i = 0; i < span.Length && trimElements.Contains(span[i]); i++)
1919 {
1920 }
1921 return i;
1922 }
1923
1925 {
1926 int num = span.Length - 1;
1927 while (num >= start && trimElements.Contains(span[num]))
1928 {
1929 num--;
1930 }
1931 return num - start + 1;
1932 }
1933
1935 {
1937 int start = ClampStart(span);
1938 int length = ClampEnd(span, start);
1939 return memory.Slice(start, length);
1940 }
1941
1943 {
1944 return memory.Slice(ClampStart(memory.Span));
1945 }
1946
1948 {
1949 return memory.Slice(0, ClampEnd(memory.Span, 0));
1950 }
1951
1953 {
1955 int start = ClampStart(span);
1956 int length = ClampEnd(span, start);
1957 return memory.Slice(start, length);
1958 }
1959
1961 {
1962 return memory.Slice(ClampStart(memory.Span));
1963 }
1964
1966 {
1967 return memory.Slice(0, ClampEnd(memory.Span, 0));
1968 }
1969
1971 {
1972 int i;
1973 for (i = 0; i < span.Length && char.IsWhiteSpace(span[i]); i++)
1974 {
1975 }
1976 int num = span.Length - 1;
1977 while (num > i && char.IsWhiteSpace(span[num]))
1978 {
1979 num--;
1980 }
1981 return span.Slice(i, num - i + 1);
1982 }
1983
1985 {
1986 int i;
1987 for (i = 0; i < span.Length && char.IsWhiteSpace(span[i]); i++)
1988 {
1989 }
1990 return span.Slice(i);
1991 }
1992
1994 {
1995 int num = span.Length - 1;
1996 while (num >= 0 && char.IsWhiteSpace(span[num]))
1997 {
1998 num--;
1999 }
2000 return span.Slice(0, num + 1);
2001 }
2002
2004 {
2005 int i;
2006 for (i = 0; i < span.Length && span[i] == trimChar; i++)
2007 {
2008 }
2009 int num = span.Length - 1;
2010 while (num > i && span[num] == trimChar)
2011 {
2012 num--;
2013 }
2014 return span.Slice(i, num - i + 1);
2015 }
2016
2018 {
2019 int i;
2020 for (i = 0; i < span.Length && span[i] == trimChar; i++)
2021 {
2022 }
2023 return span.Slice(i);
2024 }
2025
2027 {
2028 int num = span.Length - 1;
2029 while (num >= 0 && span[num] == trimChar)
2030 {
2031 num--;
2032 }
2033 return span.Slice(0, num + 1);
2034 }
2035
2037 {
2038 return span.TrimStart(trimChars).TrimEnd(trimChars);
2039 }
2040
2042 {
2043 if (trimChars.IsEmpty)
2044 {
2045 return span.TrimStart();
2046 }
2047 int i;
2048 for (i = 0; i < span.Length; i++)
2049 {
2050 int num = 0;
2051 while (num < trimChars.Length)
2052 {
2053 if (span[i] != trimChars[num])
2054 {
2055 num++;
2056 continue;
2057 }
2058 goto IL_003c;
2059 }
2060 break;
2061 IL_003c:;
2062 }
2063 return span.Slice(i);
2064 }
2065
2067 {
2068 if (trimChars.IsEmpty)
2069 {
2070 return span.TrimEnd();
2071 }
2072 int num;
2073 for (num = span.Length - 1; num >= 0; num--)
2074 {
2075 int num2 = 0;
2076 while (num2 < trimChars.Length)
2077 {
2078 if (span[num] != trimChars[num2])
2079 {
2080 num2++;
2081 continue;
2082 }
2083 goto IL_0044;
2084 }
2085 break;
2086 IL_0044:;
2087 }
2088 return span.Slice(0, num + 1);
2089 }
2090
2091 public static Span<char> Trim(this Span<char> span)
2092 {
2093 int start = ClampStart(span);
2094 int length = ClampEnd(span, start);
2095 return span.Slice(start, length);
2096 }
2097
2099 {
2100 return span.Slice(ClampStart(span));
2101 }
2102
2103 public static Span<char> TrimEnd(this Span<char> span)
2104 {
2105 return span.Slice(0, ClampEnd(span, 0));
2106 }
2107
2109 {
2110 int i;
2111 for (i = 0; i < span.Length && char.IsWhiteSpace(span[i]); i++)
2112 {
2113 }
2114 return i;
2115 }
2116
2117 private static int ClampEnd(ReadOnlySpan<char> span, int start)
2118 {
2119 int num = span.Length - 1;
2120 while (num >= start && char.IsWhiteSpace(span[num]))
2121 {
2122 num--;
2123 }
2124 return num - start + 1;
2125 }
2126}
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
static readonly CompareInfo Invariant
static CultureInfo CurrentCulture
static int IndexOfOrdinalIgnoreCase(ReadOnlySpan< char > source, ReadOnlySpan< char > value)
Definition Ordinal.cs:151
static bool EqualsIgnoreCase(ref char charA, ref char charB, int length)
Definition Ordinal.cs:57
static int LastIndexOfOrdinalIgnoreCase(ReadOnlySpan< char > source, ReadOnlySpan< char > value)
Definition Ordinal.cs:172
static int CompareStringIgnoreCase(ref char strA, int lengthA, ref char strB, int lengthB)
Definition Ordinal.cs:8
static readonly TextInfo Invariant
Definition TextInfo.cs:42
static ReadOnlySpan< char > TrimEnd(this ReadOnlySpan< char > span, ReadOnlySpan< char > trimChars)
static int CompareTo(this ReadOnlySpan< char > span, ReadOnlySpan< char > other, StringComparison comparisonType)
static int ToUpperInvariant(this ReadOnlySpan< char > source, Span< char > destination)
static bool Contains< T >(this Span< T > span, T value)
static int IndexOf(this ReadOnlySpan< char > span, ReadOnlySpan< char > value, StringComparison comparisonType)
static int IndexOf< T >(this Span< T > span, T value)
static Memory< T > TrimEnd< T >(this Memory< T > memory, T trimElement)
static int ClampStart(ReadOnlySpan< char > span)
static bool Contains(this ReadOnlySpan< char > span, ReadOnlySpan< char > value, StringComparison comparisonType)
static Span< char > TrimEnd(this Span< char > span)
static bool TryWrite(this Span< char > destination, [InterpolatedStringHandlerArgument("destination")] ref TryWriteInterpolatedStringHandler handler, out int charsWritten)
static void Reverse< T >(this Span< T > span)
static ReadOnlySpan< char > AsSpan(this string? text, int start)
static ReadOnlySpan< char > Trim(this ReadOnlySpan< char > span, ReadOnlySpan< char > trimChars)
static Memory< T > TrimStart< T >(this Memory< T > memory, T trimElement)
static bool Equals(this ReadOnlySpan< char > span, ReadOnlySpan< char > other, StringComparison comparisonType)
static void Sort< T >(this Span< T > span)
static ReadOnlyMemory< char > TrimStart(this ReadOnlyMemory< char > memory)
static int LastIndexOf< T >(this Span< T > span, T value)
static bool EndsWith(this ReadOnlySpan< char > span, ReadOnlySpan< char > value, StringComparison comparisonType)
static ReadOnlyMemory< char > AsMemory(this string? text, Range range)
static bool Overlaps< T >(this Span< T > span, ReadOnlySpan< T > other)
static bool StartsWithOrdinalIgnoreCase(this ReadOnlySpan< char > span, ReadOnlySpan< char > value)
static bool StartsWith< T >(this Span< T > span, ReadOnlySpan< T > value)
static bool IsWhiteSpace(this ReadOnlySpan< char > span)
static ReadOnlyMemory< char > AsMemory(this string? text, int start, int length)
static SpanRuneEnumerator EnumerateRunes(this ReadOnlySpan< char > span)
static int LastIndexOf(this ReadOnlySpan< char > span, ReadOnlySpan< char > value, StringComparison comparisonType)
static bool EqualsOrdinal(this ReadOnlySpan< char > span, ReadOnlySpan< char > value)
static bool EndsWithOrdinalIgnoreCase(this ReadOnlySpan< char > span, ReadOnlySpan< char > value)
static int ToLowerInvariant(this ReadOnlySpan< char > source, Span< char > destination)
static void Sort< TKey, TValue >(this Span< TKey > keys, Span< TValue > items)
static int ClampEnd(ReadOnlySpan< char > span, int start)
static bool EndsWith< T >(this Span< T > span, ReadOnlySpan< T > value)
static ReadOnlySpan< char > AsSpan(this string? text, int start, int length)
static bool EqualsOrdinalIgnoreCase(this ReadOnlySpan< char > span, ReadOnlySpan< char > value)
static Span< T > AsSpan< T >(this T[]? array, int start)
static Memory< char > TrimStart(this Memory< char > memory)
static bool SequenceEqual< T >(this Span< T > span, ReadOnlySpan< T > other)
static SpanLineEnumerator EnumerateLines(this Span< char > span)
static Memory< T > Trim< T >(this Memory< T > memory, T trimElement)
static int IndexOfAny< T >(this Span< T > span, T value0, T value1)
static int ToUpper(this ReadOnlySpan< char > source, Span< char > destination, CultureInfo? culture)
static Memory< char > Trim(this Memory< char > memory)
static void Sort< TKey, TValue, TComparer >(this Span< TKey > keys, Span< TValue > items, TComparer comparer)
static int ClampEnd< T >(ReadOnlySpan< T > span, int start, T trimElement)
static ReadOnlySpan< char > TrimEnd(this ReadOnlySpan< char > span)
static Memory< T > AsMemory< T >(this T[]? array)
static Span< char > Trim(this Span< char > span)
static ReadOnlySpan< char > AsSpan(this string? text)
static ReadOnlyMemory< char > AsMemory(this string? text, Index startIndex)
static void Sort< T, TComparer >(this Span< T > span, TComparer comparer)
static int BinarySearch< T, TComparable >(this Span< T > span, TComparable comparable)
static int ClampStart< T >(ReadOnlySpan< T > span, T trimElement)
static SpanRuneEnumerator EnumerateRunes(this Span< char > span)
static int SequenceCompareTo< T >(this Span< T > span, ReadOnlySpan< T > other)
static Memory< char > TrimEnd(this Memory< char > memory)
static void CopyTo< T >(this T[]? source, Span< T > destination)
static ReadOnlySpan< char > TrimEnd(this ReadOnlySpan< char > span, char trimChar)
static ReadOnlyMemory< char > AsMemory(this string? text, int start)
static bool TryWrite(this Span< char > destination, IFormatProvider? provider, [InterpolatedStringHandlerArgument(new string[] { "destination", "provider" })] ref TryWriteInterpolatedStringHandler handler, out int charsWritten)
static int ToLower(this ReadOnlySpan< char > source, Span< char > destination, CultureInfo? culture)
static ReadOnlySpan< char > TrimStart(this ReadOnlySpan< char > span, ReadOnlySpan< char > trimChars)
static int BinarySearch< T >(this Span< T > span, IComparable< T > comparable)
static int BinarySearch< T, TComparer >(this Span< T > span, T value, TComparer comparer)
static Span< char > TrimStart(this Span< char > span)
static ReadOnlySpan< char > TrimStart(this ReadOnlySpan< char > span, char trimChar)
static ReadOnlySpan< char > TrimStart(this ReadOnlySpan< char > span)
static bool StartsWith(this ReadOnlySpan< char > span, ReadOnlySpan< char > value, StringComparison comparisonType)
static SpanLineEnumerator EnumerateLines(this ReadOnlySpan< char > span)
static ReadOnlyMemory< char > AsMemory(this string? text)
static int LastIndexOfAny< T >(this Span< T > span, T value0, T value1)
static ReadOnlySpan< char > Trim(this ReadOnlySpan< char > span, char trimChar)
static ReadOnlyMemory< char > Trim(this ReadOnlyMemory< char > memory)
static ReadOnlyMemory< char > TrimEnd(this ReadOnlyMemory< char > memory)
static ReadOnlySpan< char > Trim(this ReadOnlySpan< char > span)
static unsafe ref byte GetArrayDataReference(Array array)
static string InvalidOperation_SpanOverlappedOperation
Definition SR.cs:1676
Definition SR.cs:7
static bool Contains(ref byte searchSpace, byte value, int length)
static int LastIndexOfAny(ref byte searchSpace, byte value0, byte value1, int length)
static int IndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref byte second, int secondLength)
static int IndexOfAny(ref byte searchSpace, byte value0, byte value1, int length)
static unsafe bool SequenceEqual(ref byte first, ref byte second, nuint length)
static int LastIndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
static void ThrowArrayTypeMismatchException()
static void ThrowArgumentOutOfRangeException(System.ExceptionArgument argument)
static void ThrowArgumentNullException(string name)
static void ThrowArgumentException(ExceptionResource resource)
static void ThrowArgumentException_OverlapAlignmentMismatch()
object? GetFormat(Type? formatType)
override bool Equals([NotNullWhen(true)] object? value)
Definition Index.cs:81
static Index Start
Definition Index.cs:10
bool AppendFormatted(object? value, int alignment=0, string? format=null)
TryWriteInterpolatedStringHandler(int literalLength, int formattedCount, Span< char > destination, IFormatProvider? provider, out bool shouldAppend)
TryWriteInterpolatedStringHandler(int literalLength, int formattedCount, Span< char > destination, out bool shouldAppend)
bool TryAppendOrInsertAlignmentIfNeeded(int startingPos, int alignment)
bool AppendFormatted(string? value, int alignment=0, string? format=null)
bool AppendFormatted(ReadOnlySpan< char > value, int alignment=0, string? format=null)
Span< T > Slice(int start)
Definition Span.cs:271
int Length
Definition Span.cs:70