Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIntPtr.cs
Go to the documentation of this file.
8
9namespace System;
10
12[CLSCompliant(false)]
13[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
14public readonly struct UIntPtr : IEquatable<nuint>, IComparable, IComparable<nuint>, ISpanFormattable, IFormattable, ISerializable, IBinaryInteger<nuint>, IBinaryNumber<nuint>, IBitwiseOperators<nuint, nuint, nuint>, INumber<nuint>, IAdditionOperators<nuint, nuint, nuint>, IAdditiveIdentity<nuint, nuint>, IComparisonOperators<nuint, nuint>, IEqualityOperators<nuint, nuint>, IDecrementOperators<nuint>, IDivisionOperators<nuint, nuint, nuint>, IIncrementOperators<nuint>, IModulusOperators<nuint, nuint, nuint>, IMultiplicativeIdentity<nuint, nuint>, IMultiplyOperators<nuint, nuint, nuint>, ISpanParseable<nuint>, IParseable<nuint>, ISubtractionOperators<nuint, nuint, nuint>, IUnaryNegationOperators<nuint, nuint>, IUnaryPlusOperators<nuint, nuint>, IShiftOperators<nuint, nuint>, IMinMaxValue<nuint>, IUnsignedNumber<nuint>
15{
16 private unsafe readonly void* _value;
17
18 [Intrinsic]
19 public static readonly UIntPtr Zero;
20
21 public static int Size
22 {
24 get
25 {
26 return 8;
27 }
28 }
29
30 public static UIntPtr MaxValue
31 {
33 get
34 {
35 return (UIntPtr)ulong.MaxValue;
36 }
37 }
38
39 public static UIntPtr MinValue
40 {
42 get
43 {
44 return (UIntPtr)0uL;
45 }
46 }
47
48 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
50
51 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
53
54 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
56
57 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
59
60 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
61 static nuint INumber<UIntPtr>.One => 1u;
62
63 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
64 static nuint INumber<UIntPtr>.Zero => 0u;
65
67 public unsafe UIntPtr(uint value)
68 {
69 _value = (void*)value;
70 }
71
73 public unsafe UIntPtr(ulong value)
74 {
75 _value = (void*)value;
76 }
77
79 public unsafe UIntPtr(void* value)
80 {
81 _value = value;
82 }
83
85 {
86 ulong uInt = info.GetUInt64("value");
87 if (Size == 4)
88 {
89 }
90 _value = (void*)uInt;
91 }
92
94 {
95 if (info == null)
96 {
97 throw new ArgumentNullException("info");
98 }
99 info.AddValue("value", ToUInt64());
100 }
101
102 public unsafe override bool Equals([NotNullWhen(true)] object? obj)
103 {
104 if (obj is UIntPtr)
105 {
106 return _value == ((UIntPtr)obj)._value;
107 }
108 return false;
109 }
110
111 public unsafe override int GetHashCode()
112 {
113 ulong num = (ulong)_value;
114 return (int)num ^ (int)(num >> 32);
115 }
116
118 public unsafe uint ToUInt32()
119 {
120 return checked((uint)_value);
121 }
122
124 public unsafe ulong ToUInt64()
125 {
126 return (ulong)_value;
127 }
128
130 public static explicit operator UIntPtr(uint value)
131 {
132 return new UIntPtr(value);
133 }
134
136 public static explicit operator UIntPtr(ulong value)
137 {
138 return new UIntPtr(value);
139 }
140
142 public unsafe static explicit operator UIntPtr(void* value)
143 {
144 return new UIntPtr(value);
145 }
146
148 public unsafe static explicit operator void*(UIntPtr value)
149 {
150 return value._value;
151 }
152
154 public unsafe static explicit operator uint(UIntPtr value)
155 {
156 return checked((uint)value._value);
157 }
158
160 public unsafe static explicit operator ulong(UIntPtr value)
161 {
162 return (ulong)value._value;
163 }
164
166 public unsafe static bool operator ==(UIntPtr value1, UIntPtr value2)
167 {
168 return value1._value == value2._value;
169 }
170
172 public unsafe static bool operator !=(UIntPtr value1, UIntPtr value2)
173 {
174 return value1._value != value2._value;
175 }
176
178 public static UIntPtr Add(UIntPtr pointer, int offset)
179 {
180 return pointer + offset;
181 }
182
184 public unsafe static UIntPtr operator +(UIntPtr pointer, int offset)
185 {
186 return (UIntPtr)((byte*)pointer._value + offset);
187 }
188
191 {
192 return pointer - offset;
193 }
194
196 public unsafe static UIntPtr operator -(UIntPtr pointer, int offset)
197 {
198 return (UIntPtr)((byte*)pointer._value - offset);
199 }
200
202 public unsafe void* ToPointer()
203 {
204 return _value;
205 }
206
207 public unsafe int CompareTo(object? value)
208 {
209 if (value == null)
210 {
211 return 1;
212 }
214 {
215 if ((nuint)_value < (nuint)uIntPtr)
216 {
217 return -1;
218 }
219 if ((nuint)_value > (nuint)uIntPtr)
220 {
221 return 1;
222 }
223 return 0;
224 }
226 }
227
228 public unsafe int CompareTo(UIntPtr value)
229 {
230 return ((ulong)_value).CompareTo((ulong)value);
231 }
232
234 public unsafe bool Equals(UIntPtr other)
235 {
236 return _value == (void*)other;
237 }
238
239 public unsafe override string ToString()
240 {
241 return ((ulong)_value).ToString();
242 }
243
244 public unsafe string ToString(string? format)
245 {
246 return ((ulong)_value).ToString(format);
247 }
248
249 public unsafe string ToString(IFormatProvider? provider)
250 {
251 return ((ulong)_value).ToString(provider);
252 }
253
254 public unsafe string ToString(string? format, IFormatProvider? provider)
255 {
256 return ((ulong)_value).ToString(format, provider);
257 }
258
260 {
261 return ((ulong)_value).TryFormat(destination, out charsWritten, format, provider);
262 }
263
264 public static UIntPtr Parse(string s)
265 {
266 return (UIntPtr)ulong.Parse(s);
267 }
268
269 public static UIntPtr Parse(string s, NumberStyles style)
270 {
271 return (UIntPtr)ulong.Parse(s, style);
272 }
273
274 public static UIntPtr Parse(string s, IFormatProvider? provider)
275 {
276 return (UIntPtr)ulong.Parse(s, provider);
277 }
278
279 public static UIntPtr Parse(string s, NumberStyles style, IFormatProvider? provider)
280 {
281 return (UIntPtr)ulong.Parse(s, style, provider);
282 }
283
285 {
286 return (UIntPtr)ulong.Parse(s, style, provider);
287 }
288
289 public static bool TryParse([NotNullWhen(true)] string? s, out UIntPtr result)
290 {
291 Unsafe.SkipInit<UIntPtr>(out result);
292 return ulong.TryParse(s, out Unsafe.As<UIntPtr, ulong>(ref result));
293 }
294
295 public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out UIntPtr result)
296 {
297 Unsafe.SkipInit<UIntPtr>(out result);
298 return ulong.TryParse(s, style, provider, out Unsafe.As<UIntPtr, ulong>(ref result));
299 }
300
301 public static bool TryParse(ReadOnlySpan<char> s, out UIntPtr result)
302 {
303 Unsafe.SkipInit<UIntPtr>(out result);
304 return ulong.TryParse(s, out Unsafe.As<UIntPtr, ulong>(ref result));
305 }
306
308 {
309 Unsafe.SkipInit<UIntPtr>(out result);
310 return ulong.TryParse(s, style, provider, out Unsafe.As<UIntPtr, ulong>(ref result));
311 }
312
313 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
314 static nuint IAdditionOperators<UIntPtr, UIntPtr, UIntPtr>.operator +(nuint left, nuint right)
315 {
316 return left + right;
317 }
318
319 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
325
326 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
328 {
330 return (nuint)BitOperations.PopCount(value);
331 }
332
333 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
339
340 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
346
347 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
353
354 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
356 {
358 return BitOperations.IsPow2((ulong)value);
359 }
360
361 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
363 {
365 return (nuint)BitOperations.Log2(value);
366 }
367
368 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
369 static nuint IBitwiseOperators<UIntPtr, UIntPtr, UIntPtr>.operator &(nuint left, nuint right)
370 {
371 return left & right;
372 }
373
374 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
375 static nuint IBitwiseOperators<UIntPtr, UIntPtr, UIntPtr>.operator |(nuint left, nuint right)
376 {
377 return left | right;
378 }
379
380 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
381 static nuint IBitwiseOperators<UIntPtr, UIntPtr, UIntPtr>.operator ^(nuint left, nuint right)
382 {
383 return left ^ right;
384 }
385
386 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
388 {
389 return ~value;
390 }
391
392 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
393 static bool IComparisonOperators<UIntPtr, UIntPtr>.operator <(nuint left, nuint right)
394 {
395 return left < right;
396 }
397
398 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
399 static bool IComparisonOperators<UIntPtr, UIntPtr>.operator <=(nuint left, nuint right)
400 {
401 return left <= right;
402 }
403
404 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
405 static bool IComparisonOperators<UIntPtr, UIntPtr>.operator >(nuint left, nuint right)
406 {
407 return left > right;
408 }
409
410 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
411 static bool IComparisonOperators<UIntPtr, UIntPtr>.operator >=(nuint left, nuint right)
412 {
413 return left >= right;
414 }
415
416 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
417 static nuint IDecrementOperators<UIntPtr>.operator --(nuint value)
418 {
419 return --value;
420 }
421
422 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
423 static nuint IDivisionOperators<UIntPtr, UIntPtr, UIntPtr>.operator /(nuint left, nuint right)
424 {
425 return left / right;
426 }
427
428 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
429 static bool IEqualityOperators<UIntPtr, UIntPtr>.operator ==(nuint left, nuint right)
430 {
431 return left == right;
432 }
433
434 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
435 static bool IEqualityOperators<UIntPtr, UIntPtr>.operator !=(nuint left, nuint right)
436 {
437 return left != right;
438 }
439
440 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
441 static nuint IIncrementOperators<UIntPtr>.operator ++(nuint value)
442 {
443 return ++value;
444 }
445
446 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
447 static nuint IModulusOperators<UIntPtr, UIntPtr, UIntPtr>.operator %(nuint left, nuint right)
448 {
449 return left % right;
450 }
451
452 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
453 static nuint IMultiplyOperators<UIntPtr, UIntPtr, UIntPtr>.operator *(nuint left, nuint right)
454 {
455 return left * right;
456 }
457
458 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
459 static nuint INumber<UIntPtr>.Abs(nuint value)
460 {
461 return value;
462 }
463
464 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
465 static nuint INumber<UIntPtr>.Clamp(nuint value, nuint min, nuint max)
466 {
467 return Math.Clamp(value, min, max);
468 }
469
470 [MethodImpl(MethodImplOptions.AggressiveInlining)]
471 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
472 static nuint INumber<UIntPtr>.Create<TOther>(TOther value)
473 {
474 if (typeof(TOther) == typeof(byte))
475 {
476 return (byte)(object)value;
477 }
478 if (typeof(TOther) == typeof(char))
479 {
480 return (char)(object)value;
481 }
482 checked
483 {
484 if (typeof(TOther) == typeof(decimal))
485 {
486 return (nuint)(ulong)(decimal)(object)value;
487 }
488 if (typeof(TOther) == typeof(double))
489 {
490 return (nuint)(double)(object)value;
491 }
492 if (typeof(TOther) == typeof(short))
493 {
494 return (nuint)(short)(object)value;
495 }
496 if (typeof(TOther) == typeof(int))
497 {
498 return (nuint)(int)(object)value;
499 }
500 if (typeof(TOther) == typeof(long))
501 {
502 return (nuint)(long)(object)value;
503 }
504 if (typeof(TOther) == typeof(IntPtr))
505 {
506 return (nuint)(nint)(IntPtr)(object)value;
507 }
508 if (typeof(TOther) == typeof(sbyte))
509 {
510 return (nuint)(sbyte)(object)value;
511 }
512 if (typeof(TOther) == typeof(float))
513 {
514 return (nuint)(float)(object)value;
515 }
516 if (typeof(TOther) == typeof(ushort))
517 {
518 return (ushort)(object)value;
519 }
520 if (typeof(TOther) == typeof(uint))
521 {
522 return (uint)(object)value;
523 }
524 if (typeof(TOther) == typeof(ulong))
525 {
526 return (nuint)(ulong)(object)value;
527 }
528 if (typeof(TOther) == typeof(UIntPtr))
529 {
530 return (UIntPtr)(object)value;
531 }
533 return 0u;
534 }
535 }
536
537 [MethodImpl(MethodImplOptions.AggressiveInlining)]
538 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
539 static nuint INumber<UIntPtr>.CreateSaturating<TOther>(TOther value)
540 {
541 if (typeof(TOther) == typeof(byte))
542 {
543 return (byte)(object)value;
544 }
545 if (typeof(TOther) == typeof(char))
546 {
547 return (char)(object)value;
548 }
549 if (typeof(TOther) == typeof(decimal))
550 {
551 decimal num = (decimal)(object)value;
552 if (!(num > (decimal)(ulong)MaxValue))
553 {
554 if (!(num < 0m))
555 {
556 return (nuint)(ulong)num;
557 }
558 return MinValue;
559 }
560 return MaxValue;
561 }
562 if (typeof(TOther) == typeof(double))
563 {
564 double num2 = (double)(object)value;
565 if (!(num2 > (double)(nint)(nuint)MaxValue))
566 {
567 if (!(num2 < 0.0))
568 {
569 return (nuint)num2;
570 }
571 return MinValue;
572 }
573 return MaxValue;
574 }
575 if (typeof(TOther) == typeof(short))
576 {
577 short num3 = (short)(object)value;
578 if (num3 >= 0)
579 {
580 return (nuint)num3;
581 }
582 return MinValue;
583 }
584 if (typeof(TOther) == typeof(int))
585 {
586 int num4 = (int)(object)value;
587 if (num4 >= 0)
588 {
589 return (nuint)num4;
590 }
591 return MinValue;
592 }
593 if (typeof(TOther) == typeof(long))
594 {
595 long num5 = (long)(object)value;
596 if (Size == 4)
597 {
598 }
599 if (num5 >= 0)
600 {
601 return (nuint)num5;
602 }
603 return MinValue;
604 }
605 if (typeof(TOther) == typeof(IntPtr))
606 {
607 IntPtr intPtr = (IntPtr)(object)value;
608 if ((nint)intPtr >= 0)
609 {
610 return (nuint)(nint)intPtr;
611 }
612 return MinValue;
613 }
614 if (typeof(TOther) == typeof(sbyte))
615 {
616 sbyte b = (sbyte)(object)value;
617 if (b >= 0)
618 {
619 return (nuint)b;
620 }
621 return MinValue;
622 }
623 if (typeof(TOther) == typeof(float))
624 {
625 float num6 = (float)(object)value;
626 if (!(num6 > (float)(nint)(nuint)MaxValue))
627 {
628 if (!(num6 < 0f))
629 {
630 return (nuint)num6;
631 }
632 return MinValue;
633 }
634 return MaxValue;
635 }
636 if (typeof(TOther) == typeof(ushort))
637 {
638 return (ushort)(object)value;
639 }
640 if (typeof(TOther) == typeof(uint))
641 {
642 return (uint)(object)value;
643 }
644 if (typeof(TOther) == typeof(ulong))
645 {
646 ulong num7 = (ulong)(object)value;
647 if (num7 <= (nuint)MaxValue)
648 {
649 return (nuint)num7;
650 }
651 return MaxValue;
652 }
653 if (typeof(TOther) == typeof(UIntPtr))
654 {
655 return (UIntPtr)(object)value;
656 }
658 return 0u;
659 }
660
661 [MethodImpl(MethodImplOptions.AggressiveInlining)]
662 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
663 static nuint INumber<UIntPtr>.CreateTruncating<TOther>(TOther value)
664 {
665 if (typeof(TOther) == typeof(byte))
666 {
667 return (byte)(object)value;
668 }
669 if (typeof(TOther) == typeof(char))
670 {
671 return (char)(object)value;
672 }
673 if (typeof(TOther) == typeof(decimal))
674 {
675 return (nuint)(ulong)(decimal)(object)value;
676 }
677 if (typeof(TOther) == typeof(double))
678 {
679 return (nuint)(double)(object)value;
680 }
681 if (typeof(TOther) == typeof(short))
682 {
683 return (nuint)(short)(object)value;
684 }
685 if (typeof(TOther) == typeof(int))
686 {
687 return (nuint)(int)(object)value;
688 }
689 if (typeof(TOther) == typeof(long))
690 {
691 return (nuint)(long)(object)value;
692 }
693 if (typeof(TOther) == typeof(IntPtr))
694 {
695 return (nuint)(nint)(IntPtr)(object)value;
696 }
697 if (typeof(TOther) == typeof(sbyte))
698 {
699 return (nuint)(sbyte)(object)value;
700 }
701 if (typeof(TOther) == typeof(float))
702 {
703 return (nuint)(float)(object)value;
704 }
705 if (typeof(TOther) == typeof(ushort))
706 {
707 return (ushort)(object)value;
708 }
709 if (typeof(TOther) == typeof(uint))
710 {
711 return (uint)(object)value;
712 }
713 if (typeof(TOther) == typeof(ulong))
714 {
715 return (nuint)(ulong)(object)value;
716 }
717 if (typeof(TOther) == typeof(UIntPtr))
718 {
719 return (UIntPtr)(object)value;
720 }
722 return 0u;
723 }
724
725 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
726 static (nuint Quotient, nuint Remainder) INumber<UIntPtr>.DivRem(nuint left, nuint right)
727 {
728 return Math.DivRem(left, right);
729 }
730
731 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
732 static nuint INumber<UIntPtr>.Max(nuint x, nuint y)
733 {
734 return Math.Max(x, y);
735 }
736
737 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
738 static nuint INumber<UIntPtr>.Min(nuint x, nuint y)
739 {
740 return Math.Min(x, y);
741 }
742
743 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
745 {
746 return Parse(s, style, provider);
747 }
748
749 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
751 {
752 return Parse(s, style, provider);
753 }
754
755 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
756 static nuint INumber<UIntPtr>.Sign(nuint value)
757 {
758 return (nuint)(int)((value != 0) ? 1u : 0u);
759 }
760
761 [MethodImpl(MethodImplOptions.AggressiveInlining)]
762 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
763 static bool INumber<UIntPtr>.TryCreate<TOther>(TOther value, out nuint result)
764 {
765 if (typeof(TOther) == typeof(byte))
766 {
767 result = (byte)(object)value;
768 return true;
769 }
770 if (typeof(TOther) == typeof(char))
771 {
772 result = (char)(object)value;
773 return true;
774 }
775 if (typeof(TOther) == typeof(decimal))
776 {
777 decimal num = (decimal)(object)value;
778 if (num < 0m || num > (decimal)(ulong)MaxValue)
779 {
780 result = 0u;
781 return false;
782 }
783 result = (nuint)(ulong)num;
784 return true;
785 }
786 if (typeof(TOther) == typeof(double))
787 {
788 double num2 = (double)(object)value;
789 if (num2 < 0.0 || num2 > (double)(nint)(nuint)MaxValue)
790 {
791 result = 0u;
792 return false;
793 }
794 result = (nuint)num2;
795 return true;
796 }
797 if (typeof(TOther) == typeof(short))
798 {
799 short num3 = (short)(object)value;
800 if (num3 < 0)
801 {
802 result = 0u;
803 return false;
804 }
805 result = (nuint)num3;
806 return true;
807 }
808 if (typeof(TOther) == typeof(int))
809 {
810 int num4 = (int)(object)value;
811 if (num4 < 0)
812 {
813 result = 0u;
814 return false;
815 }
816 result = (nuint)num4;
817 return true;
818 }
819 if (typeof(TOther) == typeof(long))
820 {
821 long num5 = (long)(object)value;
822 if (num5 < 0 || Size == 4)
823 {
824 result = 0u;
825 return false;
826 }
827 result = (nuint)num5;
828 return true;
829 }
830 if (typeof(TOther) == typeof(IntPtr))
831 {
832 IntPtr intPtr = (IntPtr)(object)value;
833 if ((nint)intPtr < 0)
834 {
835 result = 0u;
836 return false;
837 }
838 result = (nuint)(nint)intPtr;
839 return true;
840 }
841 if (typeof(TOther) == typeof(sbyte))
842 {
843 sbyte b = (sbyte)(object)value;
844 if (b < 0)
845 {
846 result = 0u;
847 return false;
848 }
849 result = (nuint)b;
850 return true;
851 }
852 if (typeof(TOther) == typeof(float))
853 {
854 float num6 = (float)(object)value;
855 if (num6 < 0f || num6 > (float)(nint)(nuint)MaxValue)
856 {
857 result = 0u;
858 return false;
859 }
860 result = (nuint)num6;
861 return true;
862 }
863 if (typeof(TOther) == typeof(ushort))
864 {
865 result = (ushort)(object)value;
866 return true;
867 }
868 if (typeof(TOther) == typeof(uint))
869 {
870 result = (uint)(object)value;
871 return true;
872 }
873 if (typeof(TOther) == typeof(ulong))
874 {
875 ulong num7 = (ulong)(object)value;
876 if (num7 > (nuint)MaxValue)
877 {
878 result = 0u;
879 return false;
880 }
881 result = (nuint)num7;
882 return true;
883 }
884 if (typeof(TOther) == typeof(UIntPtr))
885 {
886 result = (UIntPtr)(object)value;
887 return true;
888 }
890 result = 0u;
891 return false;
892 }
893
894 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
895 static bool INumber<UIntPtr>.TryParse([NotNullWhen(true)] string s, NumberStyles style, IFormatProvider provider, out nuint result)
896 {
897 return TryParse(s, style, provider, out result);
898 }
899
900 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
902 {
903 return TryParse(s, style, provider, out result);
904 }
905
906 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
908 {
909 return Parse(s, provider);
910 }
911
912 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
913 static bool IParseable<UIntPtr>.TryParse([NotNullWhen(true)] string s, IFormatProvider provider, out nuint result)
914 {
915 return TryParse(s, NumberStyles.Integer, provider, out result);
916 }
917
918 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
919 static nuint IShiftOperators<UIntPtr, UIntPtr>.operator <<(nuint value, int shiftAmount)
920 {
921 return value << shiftAmount;
922 }
923
924 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
925 static nuint IShiftOperators<UIntPtr, UIntPtr>.operator >>(nuint value, int shiftAmount)
926 {
927 return value >> shiftAmount;
928 }
929
930 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
935
936 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
938 {
939 return TryParse(s, NumberStyles.Integer, provider, out result);
940 }
941
942 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
943 static nuint ISubtractionOperators<UIntPtr, UIntPtr, UIntPtr>.operator -(nuint left, nuint right)
944 {
945 return left - right;
946 }
947
948 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
950 {
951 return 0 - value;
952 }
953
954 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
955 static nuint IUnaryPlusOperators<UIntPtr, UIntPtr>.operator +(nuint value)
956 {
957 return value;
958 }
959}
static bool Is64BitProcess
static byte Clamp(byte value, byte min, byte max)
Definition Math.cs:435
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static int DivRem(int a, int b, out int result)
Definition Math.cs:329
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static int TrailingZeroCount(int value)
static bool IsPow2(int value)
static int PopCount(uint value)
static int Log2(uint value)
static uint RotateRight(uint value, int offset)
static int LeadingZeroCount(uint value)
static uint RotateLeft(uint value, int offset)
static string Arg_MustBeUIntPtr
Definition SR.cs:312
Definition SR.cs:7
static void ThrowNotSupportedException(ExceptionResource resource)
static TResult AdditiveIdentity
static TSelf RotateRight(TSelf value, int rotateAmount)
static TSelf LeadingZeroCount(TSelf value)
static TSelf PopCount(TSelf value)
static TSelf TrailingZeroCount(TSelf value)
static TSelf RotateLeft(TSelf value, int rotateAmount)
static bool IsPow2(TSelf value)
static TSelf Log2(TSelf value)
static TSelf MinValue
static TSelf MaxValue
static TSelf Max(TSelf x, TSelf y)
static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out TSelf result)
static TSelf Parse(string s, NumberStyles style, IFormatProvider? provider)
static TSelf Sign(TSelf value)
static TSelf Min(TSelf x, TSelf y)
static TSelf One
Definition INumber.cs:10
static TSelf Zero
Definition INumber.cs:12
static TSelf Abs(TSelf value)
static TSelf Clamp(TSelf value, TSelf min, TSelf max)
static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out TSelf result)
static TSelf Parse(string s, IFormatProvider? provider)
static bool TryParse(ReadOnlySpan< char > s, IFormatProvider? provider, out TSelf result)
static TSelf Parse(ReadOnlySpan< char > s, IFormatProvider? provider)
void GetObjectData(SerializationInfo info, StreamingContext context)
unsafe string ToString(IFormatProvider? provider)
Definition UIntPtr.cs:249
static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out UIntPtr result)
Definition UIntPtr.cs:295
unsafe override bool Equals([NotNullWhen(true)] object? obj)
Definition UIntPtr.cs:102
unsafe bool Equals(UIntPtr other)
Definition UIntPtr.cs:234
static readonly UIntPtr Zero
Definition UIntPtr.cs:19
unsafe uint ToUInt32()
Definition UIntPtr.cs:118
static bool TryParse(ReadOnlySpan< char > s, NumberStyles style, IFormatProvider? provider, out UIntPtr result)
Definition UIntPtr.cs:307
static unsafe bool operator!=(UIntPtr value1, UIntPtr value2)
Definition UIntPtr.cs:172
unsafe bool TryFormat(Span< char > destination, out int charsWritten, ReadOnlySpan< char > format=default(ReadOnlySpan< char >), IFormatProvider? provider=null)
Definition UIntPtr.cs:259
unsafe int CompareTo(object? value)
Definition UIntPtr.cs:207
static UIntPtr Parse(string s, IFormatProvider? provider)
Definition UIntPtr.cs:274
static nuint IMinMaxValue< UIntPtr >. MinValue
Definition UIntPtr.cs:52
static UIntPtr Parse(string s, NumberStyles style, IFormatProvider? provider)
Definition UIntPtr.cs:279
unsafe UIntPtr(ulong value)
Definition UIntPtr.cs:73
static unsafe UIntPtr operator-(UIntPtr pointer, int offset)
Definition UIntPtr.cs:196
unsafe void * ToPointer()
Definition UIntPtr.cs:202
static unsafe bool operator==(UIntPtr value1, UIntPtr value2)
Definition UIntPtr.cs:166
static UIntPtr MaxValue
Definition UIntPtr.cs:31
static unsafe UIntPtr operator+(UIntPtr pointer, int offset)
Definition UIntPtr.cs:184
static nuint nuint Remainder INumber< UIntPtr >. DivRem(nuint left, nuint right)
Definition UIntPtr.cs:726
static UIntPtr Parse(ReadOnlySpan< char > s, NumberStyles style=NumberStyles.Integer, IFormatProvider? provider=null)
Definition UIntPtr.cs:284
static UIntPtr Subtract(UIntPtr pointer, int offset)
Definition UIntPtr.cs:190
static int Size
Definition UIntPtr.cs:22
static bool TryParse([NotNullWhen(true)] string? s, out UIntPtr result)
Definition UIntPtr.cs:289
unsafe readonly void * _value
Definition UIntPtr.cs:16
unsafe override string ToString()
Definition UIntPtr.cs:239
unsafe UIntPtr(void *value)
Definition UIntPtr.cs:79
unsafe string ToString(string? format, IFormatProvider? provider)
Definition UIntPtr.cs:254
static nuint Quotient
Definition UIntPtr.cs:726
unsafe override int GetHashCode()
Definition UIntPtr.cs:111
static UIntPtr Parse(string s)
Definition UIntPtr.cs:264
static UIntPtr MinValue
Definition UIntPtr.cs:40
static nuint IMinMaxValue< UIntPtr >. MaxValue
Definition UIntPtr.cs:55
unsafe string ToString(string? format)
Definition UIntPtr.cs:244
static bool TryParse(ReadOnlySpan< char > s, out UIntPtr result)
Definition UIntPtr.cs:301
unsafe int CompareTo(UIntPtr value)
Definition UIntPtr.cs:228
unsafe UIntPtr(SerializationInfo info, StreamingContext context)
Definition UIntPtr.cs:84
unsafe UIntPtr(uint value)
Definition UIntPtr.cs:67
static UIntPtr Parse(string s, NumberStyles style)
Definition UIntPtr.cs:269
unsafe ulong ToUInt64()
Definition UIntPtr.cs:124
static UIntPtr Add(UIntPtr pointer, int offset)
Definition UIntPtr.cs:178