@@ -35,16 +35,16 @@ public static object __new__(PythonType cls, object value) {
3535 }
3636 if ( value is IConvertible valueConvertible ) {
3737 switch ( valueConvertible . GetTypeCode ( ) ) {
38- case TypeCode . Byte : return ( SByte ) ( Byte ) value ;
39- case TypeCode . SByte : return ( SByte ) ( SByte ) value ;
40- case TypeCode . Int16 : return ( SByte ) ( Int16 ) value ;
41- case TypeCode . UInt16 : return ( SByte ) ( UInt16 ) value ;
42- case TypeCode . Int32 : return ( SByte ) ( Int32 ) value ;
43- case TypeCode . UInt32 : return ( SByte ) ( UInt32 ) value ;
44- case TypeCode . Int64 : return ( SByte ) ( Int64 ) value ;
45- case TypeCode . UInt64 : return ( SByte ) ( UInt64 ) value ;
46- case TypeCode . Single : return ( SByte ) ( Single ) value ;
47- case TypeCode . Double : return ( SByte ) ( Double ) value ;
38+ case TypeCode . Byte : return checked ( ( SByte ) ( Byte ) value ) ;
39+ case TypeCode . SByte : return checked ( ( SByte ) ( SByte ) value ) ;
40+ case TypeCode . Int16 : return checked ( ( SByte ) ( Int16 ) value ) ;
41+ case TypeCode . UInt16 : return checked ( ( SByte ) ( UInt16 ) value ) ;
42+ case TypeCode . Int32 : return checked ( ( SByte ) ( Int32 ) value ) ;
43+ case TypeCode . UInt32 : return checked ( ( SByte ) ( UInt32 ) value ) ;
44+ case TypeCode . Int64 : return checked ( ( SByte ) ( Int64 ) value ) ;
45+ case TypeCode . UInt64 : return checked ( ( SByte ) ( UInt64 ) value ) ;
46+ case TypeCode . Single : return checked ( ( SByte ) ( Single ) value ) ;
47+ case TypeCode . Double : return checked ( ( SByte ) ( Double ) value ) ;
4848 }
4949 }
5050 if ( value is String s ) {
@@ -54,11 +54,11 @@ public static object __new__(PythonType cls, object value) {
5454 throw PythonOps . ValueError ( "{0}" , ex . Message ) ;
5555 }
5656 } else if ( value is BigInteger bi ) {
57- return ( SByte ) bi ;
57+ return checked ( ( SByte ) bi ) ;
5858 } else if ( value is Extensible < BigInteger > ebi ) {
59- return ( SByte ) ebi . Value ;
59+ return checked ( ( SByte ) ebi . Value ) ;
6060 } else if ( value is Extensible < double > ed ) {
61- return ( SByte ) ed . Value ;
61+ return checked ( ( SByte ) ed . Value ) ;
6262 }
6363 throw PythonOps . TypeError ( "can't convert {0} to SByte" , PythonOps . GetPythonTypeName ( value ) ) ;
6464 }
@@ -305,16 +305,16 @@ public static object __new__(PythonType cls, object value) {
305305 }
306306 if ( value is IConvertible valueConvertible ) {
307307 switch ( valueConvertible . GetTypeCode ( ) ) {
308- case TypeCode . Byte : return ( Byte ) ( Byte ) value ;
309- case TypeCode . SByte : return ( Byte ) ( SByte ) value ;
310- case TypeCode . Int16 : return ( Byte ) ( Int16 ) value ;
311- case TypeCode . UInt16 : return ( Byte ) ( UInt16 ) value ;
312- case TypeCode . Int32 : return ( Byte ) ( Int32 ) value ;
313- case TypeCode . UInt32 : return ( Byte ) ( UInt32 ) value ;
314- case TypeCode . Int64 : return ( Byte ) ( Int64 ) value ;
315- case TypeCode . UInt64 : return ( Byte ) ( UInt64 ) value ;
316- case TypeCode . Single : return ( Byte ) ( Single ) value ;
317- case TypeCode . Double : return ( Byte ) ( Double ) value ;
308+ case TypeCode . Byte : return checked ( ( Byte ) ( Byte ) value ) ;
309+ case TypeCode . SByte : return checked ( ( Byte ) ( SByte ) value ) ;
310+ case TypeCode . Int16 : return checked ( ( Byte ) ( Int16 ) value ) ;
311+ case TypeCode . UInt16 : return checked ( ( Byte ) ( UInt16 ) value ) ;
312+ case TypeCode . Int32 : return checked ( ( Byte ) ( Int32 ) value ) ;
313+ case TypeCode . UInt32 : return checked ( ( Byte ) ( UInt32 ) value ) ;
314+ case TypeCode . Int64 : return checked ( ( Byte ) ( Int64 ) value ) ;
315+ case TypeCode . UInt64 : return checked ( ( Byte ) ( UInt64 ) value ) ;
316+ case TypeCode . Single : return checked ( ( Byte ) ( Single ) value ) ;
317+ case TypeCode . Double : return checked ( ( Byte ) ( Double ) value ) ;
318318 }
319319 }
320320 if ( value is String s ) {
@@ -324,11 +324,11 @@ public static object __new__(PythonType cls, object value) {
324324 throw PythonOps . ValueError ( "{0}" , ex . Message ) ;
325325 }
326326 } else if ( value is BigInteger bi ) {
327- return ( Byte ) bi ;
327+ return checked ( ( Byte ) bi ) ;
328328 } else if ( value is Extensible < BigInteger > ebi ) {
329- return ( Byte ) ebi . Value ;
329+ return checked ( ( Byte ) ebi . Value ) ;
330330 } else if ( value is Extensible < double > ed ) {
331- return ( Byte ) ed . Value ;
331+ return checked ( ( Byte ) ed . Value ) ;
332332 }
333333 throw PythonOps . TypeError ( "can't convert {0} to Byte" , PythonOps . GetPythonTypeName ( value ) ) ;
334334 }
@@ -657,16 +657,16 @@ public static object __new__(PythonType cls, object value) {
657657 }
658658 if ( value is IConvertible valueConvertible ) {
659659 switch ( valueConvertible . GetTypeCode ( ) ) {
660- case TypeCode . Byte : return ( Int16 ) ( Byte ) value ;
661- case TypeCode . SByte : return ( Int16 ) ( SByte ) value ;
662- case TypeCode . Int16 : return ( Int16 ) ( Int16 ) value ;
663- case TypeCode . UInt16 : return ( Int16 ) ( UInt16 ) value ;
664- case TypeCode . Int32 : return ( Int16 ) ( Int32 ) value ;
665- case TypeCode . UInt32 : return ( Int16 ) ( UInt32 ) value ;
666- case TypeCode . Int64 : return ( Int16 ) ( Int64 ) value ;
667- case TypeCode . UInt64 : return ( Int16 ) ( UInt64 ) value ;
668- case TypeCode . Single : return ( Int16 ) ( Single ) value ;
669- case TypeCode . Double : return ( Int16 ) ( Double ) value ;
660+ case TypeCode . Byte : return checked ( ( Int16 ) ( Byte ) value ) ;
661+ case TypeCode . SByte : return checked ( ( Int16 ) ( SByte ) value ) ;
662+ case TypeCode . Int16 : return checked ( ( Int16 ) ( Int16 ) value ) ;
663+ case TypeCode . UInt16 : return checked ( ( Int16 ) ( UInt16 ) value ) ;
664+ case TypeCode . Int32 : return checked ( ( Int16 ) ( Int32 ) value ) ;
665+ case TypeCode . UInt32 : return checked ( ( Int16 ) ( UInt32 ) value ) ;
666+ case TypeCode . Int64 : return checked ( ( Int16 ) ( Int64 ) value ) ;
667+ case TypeCode . UInt64 : return checked ( ( Int16 ) ( UInt64 ) value ) ;
668+ case TypeCode . Single : return checked ( ( Int16 ) ( Single ) value ) ;
669+ case TypeCode . Double : return checked ( ( Int16 ) ( Double ) value ) ;
670670 }
671671 }
672672 if ( value is String s ) {
@@ -676,11 +676,11 @@ public static object __new__(PythonType cls, object value) {
676676 throw PythonOps . ValueError ( "{0}" , ex . Message ) ;
677677 }
678678 } else if ( value is BigInteger bi ) {
679- return ( Int16 ) bi ;
679+ return checked ( ( Int16 ) bi ) ;
680680 } else if ( value is Extensible < BigInteger > ebi ) {
681- return ( Int16 ) ebi . Value ;
681+ return checked ( ( Int16 ) ebi . Value ) ;
682682 } else if ( value is Extensible < double > ed ) {
683- return ( Int16 ) ed . Value ;
683+ return checked ( ( Int16 ) ed . Value ) ;
684684 }
685685 throw PythonOps . TypeError ( "can't convert {0} to Int16" , PythonOps . GetPythonTypeName ( value ) ) ;
686686 }
@@ -932,16 +932,16 @@ public static object __new__(PythonType cls, object value) {
932932 }
933933 if ( value is IConvertible valueConvertible ) {
934934 switch ( valueConvertible . GetTypeCode ( ) ) {
935- case TypeCode . Byte : return ( UInt16 ) ( Byte ) value ;
936- case TypeCode . SByte : return ( UInt16 ) ( SByte ) value ;
937- case TypeCode . Int16 : return ( UInt16 ) ( Int16 ) value ;
938- case TypeCode . UInt16 : return ( UInt16 ) ( UInt16 ) value ;
939- case TypeCode . Int32 : return ( UInt16 ) ( Int32 ) value ;
940- case TypeCode . UInt32 : return ( UInt16 ) ( UInt32 ) value ;
941- case TypeCode . Int64 : return ( UInt16 ) ( Int64 ) value ;
942- case TypeCode . UInt64 : return ( UInt16 ) ( UInt64 ) value ;
943- case TypeCode . Single : return ( UInt16 ) ( Single ) value ;
944- case TypeCode . Double : return ( UInt16 ) ( Double ) value ;
935+ case TypeCode . Byte : return checked ( ( UInt16 ) ( Byte ) value ) ;
936+ case TypeCode . SByte : return checked ( ( UInt16 ) ( SByte ) value ) ;
937+ case TypeCode . Int16 : return checked ( ( UInt16 ) ( Int16 ) value ) ;
938+ case TypeCode . UInt16 : return checked ( ( UInt16 ) ( UInt16 ) value ) ;
939+ case TypeCode . Int32 : return checked ( ( UInt16 ) ( Int32 ) value ) ;
940+ case TypeCode . UInt32 : return checked ( ( UInt16 ) ( UInt32 ) value ) ;
941+ case TypeCode . Int64 : return checked ( ( UInt16 ) ( Int64 ) value ) ;
942+ case TypeCode . UInt64 : return checked ( ( UInt16 ) ( UInt64 ) value ) ;
943+ case TypeCode . Single : return checked ( ( UInt16 ) ( Single ) value ) ;
944+ case TypeCode . Double : return checked ( ( UInt16 ) ( Double ) value ) ;
945945 }
946946 }
947947 if ( value is String s ) {
@@ -951,11 +951,11 @@ public static object __new__(PythonType cls, object value) {
951951 throw PythonOps . ValueError ( "{0}" , ex . Message ) ;
952952 }
953953 } else if ( value is BigInteger bi ) {
954- return ( UInt16 ) bi ;
954+ return checked ( ( UInt16 ) bi ) ;
955955 } else if ( value is Extensible < BigInteger > ebi ) {
956- return ( UInt16 ) ebi . Value ;
956+ return checked ( ( UInt16 ) ebi . Value ) ;
957957 } else if ( value is Extensible < double > ed ) {
958- return ( UInt16 ) ed . Value ;
958+ return checked ( ( UInt16 ) ed . Value ) ;
959959 }
960960 throw PythonOps . TypeError ( "can't convert {0} to UInt16" , PythonOps . GetPythonTypeName ( value ) ) ;
961961 }
@@ -1294,16 +1294,16 @@ public static object __new__(PythonType cls, object value) {
12941294 }
12951295 if ( value is IConvertible valueConvertible ) {
12961296 switch ( valueConvertible . GetTypeCode ( ) ) {
1297- case TypeCode . Byte : return ( Int32 ) ( Byte ) value ;
1298- case TypeCode . SByte : return ( Int32 ) ( SByte ) value ;
1299- case TypeCode . Int16 : return ( Int32 ) ( Int16 ) value ;
1300- case TypeCode . UInt16 : return ( Int32 ) ( UInt16 ) value ;
1301- case TypeCode . Int32 : return ( Int32 ) ( Int32 ) value ;
1302- case TypeCode . UInt32 : return ( Int32 ) ( UInt32 ) value ;
1303- case TypeCode . Int64 : return ( Int32 ) ( Int64 ) value ;
1304- case TypeCode . UInt64 : return ( Int32 ) ( UInt64 ) value ;
1305- case TypeCode . Single : return ( Int32 ) ( Single ) value ;
1306- case TypeCode . Double : return ( Int32 ) ( Double ) value ;
1297+ case TypeCode . Byte : return checked ( ( Int32 ) ( Byte ) value ) ;
1298+ case TypeCode . SByte : return checked ( ( Int32 ) ( SByte ) value ) ;
1299+ case TypeCode . Int16 : return checked ( ( Int32 ) ( Int16 ) value ) ;
1300+ case TypeCode . UInt16 : return checked ( ( Int32 ) ( UInt16 ) value ) ;
1301+ case TypeCode . Int32 : return checked ( ( Int32 ) ( Int32 ) value ) ;
1302+ case TypeCode . UInt32 : return checked ( ( Int32 ) ( UInt32 ) value ) ;
1303+ case TypeCode . Int64 : return checked ( ( Int32 ) ( Int64 ) value ) ;
1304+ case TypeCode . UInt64 : return checked ( ( Int32 ) ( UInt64 ) value ) ;
1305+ case TypeCode . Single : return checked ( ( Int32 ) ( Single ) value ) ;
1306+ case TypeCode . Double : return checked ( ( Int32 ) ( Double ) value ) ;
13071307 }
13081308 }
13091309 if ( value is String s ) {
@@ -1313,11 +1313,11 @@ public static object __new__(PythonType cls, object value) {
13131313 throw PythonOps . ValueError ( "{0}" , ex . Message ) ;
13141314 }
13151315 } else if ( value is BigInteger bi ) {
1316- return ( Int32 ) bi ;
1316+ return checked ( ( Int32 ) bi ) ;
13171317 } else if ( value is Extensible < BigInteger > ebi ) {
1318- return ( Int32 ) ebi . Value ;
1318+ return checked ( ( Int32 ) ebi . Value ) ;
13191319 } else if ( value is Extensible < double > ed ) {
1320- return ( Int32 ) ed . Value ;
1320+ return checked ( ( Int32 ) ed . Value ) ;
13211321 }
13221322 throw PythonOps . TypeError ( "can't convert {0} to Int32" , PythonOps . GetPythonTypeName ( value ) ) ;
13231323 }
@@ -1544,16 +1544,16 @@ public static object __new__(PythonType cls, object value) {
15441544 }
15451545 if ( value is IConvertible valueConvertible ) {
15461546 switch ( valueConvertible . GetTypeCode ( ) ) {
1547- case TypeCode . Byte : return ( UInt32 ) ( Byte ) value ;
1548- case TypeCode . SByte : return ( UInt32 ) ( SByte ) value ;
1549- case TypeCode . Int16 : return ( UInt32 ) ( Int16 ) value ;
1550- case TypeCode . UInt16 : return ( UInt32 ) ( UInt16 ) value ;
1551- case TypeCode . Int32 : return ( UInt32 ) ( Int32 ) value ;
1552- case TypeCode . UInt32 : return ( UInt32 ) ( UInt32 ) value ;
1553- case TypeCode . Int64 : return ( UInt32 ) ( Int64 ) value ;
1554- case TypeCode . UInt64 : return ( UInt32 ) ( UInt64 ) value ;
1555- case TypeCode . Single : return ( UInt32 ) ( Single ) value ;
1556- case TypeCode . Double : return ( UInt32 ) ( Double ) value ;
1547+ case TypeCode . Byte : return checked ( ( UInt32 ) ( Byte ) value ) ;
1548+ case TypeCode . SByte : return checked ( ( UInt32 ) ( SByte ) value ) ;
1549+ case TypeCode . Int16 : return checked ( ( UInt32 ) ( Int16 ) value ) ;
1550+ case TypeCode . UInt16 : return checked ( ( UInt32 ) ( UInt16 ) value ) ;
1551+ case TypeCode . Int32 : return checked ( ( UInt32 ) ( Int32 ) value ) ;
1552+ case TypeCode . UInt32 : return checked ( ( UInt32 ) ( UInt32 ) value ) ;
1553+ case TypeCode . Int64 : return checked ( ( UInt32 ) ( Int64 ) value ) ;
1554+ case TypeCode . UInt64 : return checked ( ( UInt32 ) ( UInt64 ) value ) ;
1555+ case TypeCode . Single : return checked ( ( UInt32 ) ( Single ) value ) ;
1556+ case TypeCode . Double : return checked ( ( UInt32 ) ( Double ) value ) ;
15571557 }
15581558 }
15591559 if ( value is String s ) {
@@ -1563,11 +1563,11 @@ public static object __new__(PythonType cls, object value) {
15631563 throw PythonOps . ValueError ( "{0}" , ex . Message ) ;
15641564 }
15651565 } else if ( value is BigInteger bi ) {
1566- return ( UInt32 ) bi ;
1566+ return checked ( ( UInt32 ) bi ) ;
15671567 } else if ( value is Extensible < BigInteger > ebi ) {
1568- return ( UInt32 ) ebi . Value ;
1568+ return checked ( ( UInt32 ) ebi . Value ) ;
15691569 } else if ( value is Extensible < double > ed ) {
1570- return ( UInt32 ) ed . Value ;
1570+ return checked ( ( UInt32 ) ed . Value ) ;
15711571 }
15721572 throw PythonOps . TypeError ( "can't convert {0} to UInt32" , PythonOps . GetPythonTypeName ( value ) ) ;
15731573 }
@@ -1906,16 +1906,16 @@ public static object __new__(PythonType cls, object value) {
19061906 }
19071907 if ( value is IConvertible valueConvertible ) {
19081908 switch ( valueConvertible . GetTypeCode ( ) ) {
1909- case TypeCode . Byte : return ( Int64 ) ( Byte ) value ;
1910- case TypeCode . SByte : return ( Int64 ) ( SByte ) value ;
1911- case TypeCode . Int16 : return ( Int64 ) ( Int16 ) value ;
1912- case TypeCode . UInt16 : return ( Int64 ) ( UInt16 ) value ;
1913- case TypeCode . Int32 : return ( Int64 ) ( Int32 ) value ;
1914- case TypeCode . UInt32 : return ( Int64 ) ( UInt32 ) value ;
1915- case TypeCode . Int64 : return ( Int64 ) ( Int64 ) value ;
1916- case TypeCode . UInt64 : return ( Int64 ) ( UInt64 ) value ;
1917- case TypeCode . Single : return ( Int64 ) ( Single ) value ;
1918- case TypeCode . Double : return ( Int64 ) ( Double ) value ;
1909+ case TypeCode . Byte : return checked ( ( Int64 ) ( Byte ) value ) ;
1910+ case TypeCode . SByte : return checked ( ( Int64 ) ( SByte ) value ) ;
1911+ case TypeCode . Int16 : return checked ( ( Int64 ) ( Int16 ) value ) ;
1912+ case TypeCode . UInt16 : return checked ( ( Int64 ) ( UInt16 ) value ) ;
1913+ case TypeCode . Int32 : return checked ( ( Int64 ) ( Int32 ) value ) ;
1914+ case TypeCode . UInt32 : return checked ( ( Int64 ) ( UInt32 ) value ) ;
1915+ case TypeCode . Int64 : return checked ( ( Int64 ) ( Int64 ) value ) ;
1916+ case TypeCode . UInt64 : return checked ( ( Int64 ) ( UInt64 ) value ) ;
1917+ case TypeCode . Single : return checked ( ( Int64 ) ( Single ) value ) ;
1918+ case TypeCode . Double : return checked ( ( Int64 ) ( Double ) value ) ;
19191919 }
19201920 }
19211921 if ( value is String s ) {
@@ -1925,11 +1925,11 @@ public static object __new__(PythonType cls, object value) {
19251925 throw PythonOps . ValueError ( "{0}" , ex . Message ) ;
19261926 }
19271927 } else if ( value is BigInteger bi ) {
1928- return ( Int64 ) bi ;
1928+ return checked ( ( Int64 ) bi ) ;
19291929 } else if ( value is Extensible < BigInteger > ebi ) {
1930- return ( Int64 ) ebi . Value ;
1930+ return checked ( ( Int64 ) ebi . Value ) ;
19311931 } else if ( value is Extensible < double > ed ) {
1932- return ( Int64 ) ed . Value ;
1932+ return checked ( ( Int64 ) ed . Value ) ;
19331933 }
19341934 throw PythonOps . TypeError ( "can't convert {0} to Int64" , PythonOps . GetPythonTypeName ( value ) ) ;
19351935 }
@@ -2184,16 +2184,16 @@ public static object __new__(PythonType cls, object value) {
21842184 }
21852185 if ( value is IConvertible valueConvertible ) {
21862186 switch ( valueConvertible . GetTypeCode ( ) ) {
2187- case TypeCode . Byte : return ( UInt64 ) ( Byte ) value ;
2188- case TypeCode . SByte : return ( UInt64 ) ( SByte ) value ;
2189- case TypeCode . Int16 : return ( UInt64 ) ( Int16 ) value ;
2190- case TypeCode . UInt16 : return ( UInt64 ) ( UInt16 ) value ;
2191- case TypeCode . Int32 : return ( UInt64 ) ( Int32 ) value ;
2192- case TypeCode . UInt32 : return ( UInt64 ) ( UInt32 ) value ;
2193- case TypeCode . Int64 : return ( UInt64 ) ( Int64 ) value ;
2194- case TypeCode . UInt64 : return ( UInt64 ) ( UInt64 ) value ;
2195- case TypeCode . Single : return ( UInt64 ) ( Single ) value ;
2196- case TypeCode . Double : return ( UInt64 ) ( Double ) value ;
2187+ case TypeCode . Byte : return checked ( ( UInt64 ) ( Byte ) value ) ;
2188+ case TypeCode . SByte : return checked ( ( UInt64 ) ( SByte ) value ) ;
2189+ case TypeCode . Int16 : return checked ( ( UInt64 ) ( Int16 ) value ) ;
2190+ case TypeCode . UInt16 : return checked ( ( UInt64 ) ( UInt16 ) value ) ;
2191+ case TypeCode . Int32 : return checked ( ( UInt64 ) ( Int32 ) value ) ;
2192+ case TypeCode . UInt32 : return checked ( ( UInt64 ) ( UInt32 ) value ) ;
2193+ case TypeCode . Int64 : return checked ( ( UInt64 ) ( Int64 ) value ) ;
2194+ case TypeCode . UInt64 : return checked ( ( UInt64 ) ( UInt64 ) value ) ;
2195+ case TypeCode . Single : return checked ( ( UInt64 ) ( Single ) value ) ;
2196+ case TypeCode . Double : return checked ( ( UInt64 ) ( Double ) value ) ;
21972197 }
21982198 }
21992199 if ( value is String s ) {
@@ -2203,11 +2203,11 @@ public static object __new__(PythonType cls, object value) {
22032203 throw PythonOps . ValueError ( "{0}" , ex . Message ) ;
22042204 }
22052205 } else if ( value is BigInteger bi ) {
2206- return ( UInt64 ) bi ;
2206+ return checked ( ( UInt64 ) bi ) ;
22072207 } else if ( value is Extensible < BigInteger > ebi ) {
2208- return ( UInt64 ) ebi . Value ;
2208+ return checked ( ( UInt64 ) ebi . Value ) ;
22092209 } else if ( value is Extensible < double > ed ) {
2210- return ( UInt64 ) ed . Value ;
2210+ return checked ( ( UInt64 ) ed . Value ) ;
22112211 }
22122212 throw PythonOps . TypeError ( "can't convert {0} to UInt64" , PythonOps . GetPythonTypeName ( value ) ) ;
22132213 }
0 commit comments