From bedb44582e159c0d8c9ee53b7cf4a4be095dc606 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Sun, 6 Feb 2022 14:16:00 +0100 Subject: [PATCH] fix (uint) unboxing on fields "int flags" --- src/TL.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TL.cs b/src/TL.cs index 4046cb3..6dff413 100644 --- a/src/TL.cs +++ b/src/TL.cs @@ -46,7 +46,7 @@ namespace TL if (((ifFlag = field.GetCustomAttribute()) != null) && (flags & (1U << ifFlag.Bit)) == 0) continue; object value = field.GetValue(obj); writer.WriteTLValue(value, field.FieldType); - if (field.Name == "flags") flags = (uint)value; + if (field.Name == "flags" && field.FieldType.IsEnum) flags = (uint)value; } } @@ -70,7 +70,7 @@ namespace TL if (((ifFlag = field.GetCustomAttribute()) != null) && (flags & (1U << ifFlag.Bit)) == 0) continue; object value = reader.ReadTLValue(field.FieldType); field.SetValue(obj, value); - if (field.Name == "flags") flags = (uint)value; + if (field.Name == "flags" && field.FieldType.IsEnum) flags = (uint)value; else if (field.Name == "access_hash") reader.Client?.UpdateAccessHash(obj, type, value); } return (IObject)obj;