@@ -5,7 +5,8 @@ namespace Backdash.Core;
55
66static class ThrowHelpers
77{
8- public static void ThrowIfArgumentOutOfBounds ( int argument ,
8+ public static void ThrowIfArgumentOutOfBounds (
9+ int argument ,
910 int min = int . MinValue ,
1011 int max = int . MaxValue ,
1112 [ CallerArgumentExpression ( nameof ( argument ) ) ]
@@ -15,37 +16,10 @@ public static void ThrowIfArgumentOutOfBounds(int argument,
1516 throw new ArgumentOutOfRangeException ( argument . ToString ( CultureInfo . InvariantCulture ) , paramName ) ;
1617 }
1718
18- public static void ThrowIfArgumentIsZeroOrLess ( int argument ,
19- [ CallerArgumentExpression ( nameof ( argument ) ) ]
20- string ? paramName = null )
21- {
22- if ( argument <= 0 )
23- throw new ArgumentOutOfRangeException ( argument . ToString ( CultureInfo . InvariantCulture ) , paramName ) ;
24- }
25-
26- public static void ThrowIfArgumentIsNegative ( int argument ,
27- [ CallerArgumentExpression ( nameof ( argument ) ) ]
28- string ? paramName = null )
29- {
30- if ( argument < 0 )
31- throw new ArgumentOutOfRangeException ( argument . ToString ( CultureInfo . InvariantCulture ) , paramName ) ;
32- }
33-
34- public static void ThrowIfTypeTooBigForStack < T > ( ) where T : unmanaged
35- {
36- var size = Mem . SizeOf < T > ( ) ;
37- if ( size > Mem . MaxStackLimit )
38- throw new NetcodeException ( $ "{ typeof ( T ) . Name } size too big for stack: { size } ") ;
39- }
40-
41- public static Exception StructMustNotHaveReferenceTypeMembers ( ) =>
42- new ArgumentException ( "Input struct must not have reference type members" ) ;
43-
44-
4519 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
4620 public static void ThrowIfTypeIsReferenceOrContainsReferences < T > ( ) where T : struct
4721 {
4822 if ( Mem . IsReferenceOrContainsReferences < T > ( ) )
49- throw StructMustNotHaveReferenceTypeMembers ( ) ;
23+ throw new ArgumentException ( $ "Type { typeof ( T ) . FullName } must not have reference type members" ) ;
5024 }
5125}
0 commit comments