| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,8 +12,12 @@ public sealed class TupleCodec<TTuple> : IPyObjectEncoder, IPyObjectDecoder | |||
| 12 | 12 | public static TupleCodec<TTuple> Instance { get; } = new TupleCodec<TTuple>(); | |
| 13 | 13 | ||
| 14 | 14 | public bool CanEncode(Type type) | |
| 15 | - => type.Namespace == typeof(TTuple).Namespace && type.Name.StartsWith(typeof(TTuple).Name + '`') | ||
| 16 | - || type == typeof(object) || type == typeof(TTuple); | ||
| 15 | + { | ||
| 16 | + if (type == typeof(object) || type == typeof(TTuple)) return true; | ||
| 17 | + return type.Namespace == typeof(TTuple).Namespace | ||
| 18 | + // generic versions of tuples are named Tuple`TYPE_ARG_COUNT | ||
| 19 | + && type.Name.StartsWith(typeof(TTuple).Name + '`'); | ||
| 20 | + } | ||
| 17 | 21 | ||
| 18 | 22 | public PyObject TryEncode(object value) | |
| 19 | 23 | { | |
@@ -36,7 +40,7 @@ public PyObject TryEncode(object value) | |||
| 36 | 40 | Runtime.PyTuple_SetItem(tuple, fieldIndex, pyItem); | |
| 37 | 41 | fieldIndex++; | |
| 38 | 42 | } | |
| 39 | - return new PyTuple(Runtime.SelfIncRef(tuple)); | ||
| 43 | + return new PyTuple(tuple); | ||
| 40 | 44 | } | |
| 41 | 45 | ||
| 42 | 46 | public bool CanDecode(PyObject objectType, Type targetType) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments