@@ -141,16 +141,17 @@ public void SequenceDecoderTest()
141141
142142 //SequenceConverter can only convert to any ICollection
143143 var pyList = new PyList(items.ToArray());
144+ var listType = pyList.GetPythonType();
144145 //it can convert a PyList, since PyList satisfies the python sequence protocol
145146
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>)));
150151
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>)));
154155
155156 //convert to collection of int
156157 ICollection<int> intCollection = null;
@@ -380,7 +381,7 @@ public void As_Object_AffectedByDecoders()
380381
381382 public class EverythingElseToSelfDecoder : IPyObjectDecoder
382383 {
383- public bool CanDecode(PyObject objectType, Type targetType)
384+ public bool CanDecode(PyType objectType, Type targetType)
384385 {
385386 return targetType.IsAssignableFrom(typeof(EverythingElseToSelfDecoder));
386387 }
@@ -399,7 +400,7 @@ public ValueErrorWrapper(string message) : base(message) { }
399400
400401 class ValueErrorCodec : IPyObjectEncoder, IPyObjectDecoder
401402 {
402- public bool CanDecode(PyObject objectType, Type targetType)
403+ public bool CanDecode(PyType objectType, Type targetType)
403404 => this.CanEncode(targetType)
404405 && PythonReferenceComparer.Instance.Equals(objectType, PythonEngine.Eval("ValueError"));
405406
@@ -424,7 +425,7 @@ class InstancelessExceptionDecoder : IPyObjectDecoder
424425 {
425426 readonly PyObject PyErr = Py.Import("clr.interop").GetAttr("PyErr");
426427
427- public bool CanDecode(PyObject objectType, Type targetType)
428+ public bool CanDecode(PyType objectType, Type targetType)
428429 => PythonReferenceComparer.Instance.Equals(PyErr, objectType);
429430
430431 public bool TryDecode<T>(PyObject pyObj, out T value)
@@ -466,7 +467,7 @@ public DecoderReturningPredefinedValue(PyObject objectType, TTarget decodeResult
466467 this.DecodeResult = decodeResult;
467468 }
468469
469- public bool CanDecode(PyObject objectType, Type targetType)
470+ public bool CanDecode(PyType objectType, Type targetType)
470471 => objectType.Handle == TheOnlySupportedSourceType.Handle
471472 && targetType == typeof(TTarget);
472473 public bool TryDecode<T>(PyObject pyObj, out T value)
@@ -485,7 +486,7 @@ public static void Setup()
485486 PyObjectConversions.RegisterDecoder(new DateTimeDecoder());
486487 }
487488
488- public bool CanDecode(PyObject objectType, Type targetType)
489+ public bool CanDecode(PyType objectType, Type targetType)
489490 {
490491 return targetType == typeof(DateTime);
491492 }
0 commit comments