@@ -141,16 +141,17 @@ public void SequenceDecoderTest()
141
141
142
142
//SequenceConverter can only convert to any ICollection
143
143
var pyList = new PyList ( items . ToArray ( ) ) ;
144
+ var listType = pyList . GetPythonType ( ) ;
144
145
//it can convert a PyList, since PyList satisfies the python sequence protocol
145
146
146
- Assert . IsFalse ( codec . CanDecode ( pyList , typeof ( bool ) ) ) ;
147
- Assert . IsFalse ( codec . CanDecode ( pyList , typeof ( IList < int > ) ) ) ;
148
- Assert . IsFalse ( codec . CanDecode ( pyList , typeof ( System . Collections . IEnumerable ) ) ) ;
149
- Assert . IsFalse ( codec . CanDecode ( pyList , typeof ( IEnumerable < int > ) ) ) ;
147
+ Assert . IsFalse ( codec . CanDecode ( listType , typeof ( bool ) ) ) ;
148
+ Assert . IsFalse ( codec . CanDecode ( listType , typeof ( IList < int > ) ) ) ;
149
+ Assert . IsFalse ( codec . CanDecode ( listType , typeof ( System . Collections . IEnumerable ) ) ) ;
150
+ Assert . IsFalse ( codec . CanDecode ( listType , typeof ( IEnumerable < int > ) ) ) ;
150
151
151
- Assert . IsTrue ( codec . CanDecode ( pyList , typeof ( ICollection < float > ) ) ) ;
152
- Assert . IsTrue ( codec . CanDecode ( pyList , typeof ( ICollection < string > ) ) ) ;
153
- Assert . IsTrue ( codec . CanDecode ( pyList , typeof ( ICollection < int > ) ) ) ;
152
+ Assert . IsTrue ( codec . CanDecode ( listType , typeof ( ICollection < float > ) ) ) ;
153
+ Assert . IsTrue ( codec . CanDecode ( listType , typeof ( ICollection < string > ) ) ) ;
154
+ Assert . IsTrue ( codec . CanDecode ( listType , typeof ( ICollection < int > ) ) ) ;
154
155
155
156
//convert to collection of int
156
157
ICollection < int > intCollection = null ;
@@ -380,7 +381,7 @@ public void As_Object_AffectedByDecoders()
380
381
381
382
public class EverythingElseToSelfDecoder : IPyObjectDecoder
382
383
{
383
- public bool CanDecode ( PyObject objectType , Type targetType )
384
+ public bool CanDecode ( PyType objectType , Type targetType )
384
385
{
385
386
return targetType . IsAssignableFrom ( typeof ( EverythingElseToSelfDecoder ) ) ;
386
387
}
@@ -399,7 +400,7 @@ public ValueErrorWrapper(string message) : base(message) { }
399
400
400
401
class ValueErrorCodec : IPyObjectEncoder , IPyObjectDecoder
401
402
{
402
- public bool CanDecode ( PyObject objectType , Type targetType )
403
+ public bool CanDecode ( PyType objectType , Type targetType )
403
404
=> this . CanEncode ( targetType )
404
405
&& PythonReferenceComparer . Instance . Equals ( objectType , PythonEngine . Eval ( "ValueError" ) ) ;
405
406
@@ -424,7 +425,7 @@ class InstancelessExceptionDecoder : IPyObjectDecoder
424
425
{
425
426
readonly PyObject PyErr = Py . Import ( "clr.interop" ) . GetAttr ( "PyErr" ) ;
426
427
427
- public bool CanDecode ( PyObject objectType , Type targetType )
428
+ public bool CanDecode ( PyType objectType , Type targetType )
428
429
=> PythonReferenceComparer . Instance . Equals ( PyErr , objectType ) ;
429
430
430
431
public bool TryDecode < T > ( PyObject pyObj , out T value )
@@ -466,7 +467,7 @@ public DecoderReturningPredefinedValue(PyObject objectType, TTarget decodeResult
466
467
this . DecodeResult = decodeResult ;
467
468
}
468
469
469
- public bool CanDecode ( PyObject objectType , Type targetType )
470
+ public bool CanDecode ( PyType objectType , Type targetType )
470
471
=> objectType . Handle == TheOnlySupportedSourceType . Handle
471
472
&& targetType == typeof ( TTarget ) ;
472
473
public bool TryDecode < T > ( PyObject pyObj , out T value )
@@ -485,7 +486,7 @@ public static void Setup()
485
486
PyObjectConversions . RegisterDecoder ( new DateTimeDecoder ( ) ) ;
486
487
}
487
488
488
- public bool CanDecode ( PyObject objectType , Type targetType )
489
+ public bool CanDecode ( PyType objectType , Type targetType )
489
490
{
490
491
return targetType == typeof ( DateTime ) ;
491
492
}
0 commit comments