Fix crash on Gzipped Vector result

This commit is contained in:
Wizou 2024-04-14 13:25:45 +02:00
parent 741422e17f
commit 8c271f50f6
4 changed files with 7 additions and 5 deletions

View file

@ -25,8 +25,10 @@ namespace WTelegramClientTest
// We collect all infos about the users/chats so that updates can be printed with their names
var dialogs = await Client.Messages_GetAllDialogs(); // dialogs = groups/channels/users
dialogs.CollectUsersChats(Manager.Users, Manager.Chats);
Console.ReadKey();
}
} // WTelegram.Client gets disposed when exiting this scope
//Manager.SaveState("Updates.state"); // if you want to resume missed updates on the next run (see WithUpdateManager above)
}

View file

@ -85,7 +85,7 @@ public class MTProtoGenerator : IIncrementalGenerator
continue;
}
if (id == 0x3072CFA1) // GzipPacked
makeTL.AppendLine($"\t\t\t0x{id:X8} => reader.ReadTLGzipped(),");
makeTL.AppendLine($"\t\t\t0x{id:X8} => (IObject)reader.ReadTLGzipped(typeof(IObject)),");
else if (name != "Null" && (ns != "TL.Methods" || name == "Ping"))
makeTL.AppendLine($"\t\t\t0x{id:X8} => new {(ns == "TL" ? "" : ns + '.')}{name}().ReadTL(reader),");
var override_ = symbol.BaseType == object_ ? "" : "override ";

View file

@ -570,7 +570,7 @@ namespace WTelegram
if (peek == Layer.RpcErrorCtor)
result = reader.ReadTLObject(Layer.RpcErrorCtor);
else if (peek == Layer.GZipedCtor)
result = reader.ReadTLGzipped();
result = reader.ReadTLGzipped(rpc.type);
else
{
reader.BaseStream.Position -= 4;

View file

@ -350,10 +350,10 @@ namespace TL
writer.Write(0); // null arrays/strings are serialized as empty
}
internal static IObject ReadTLGzipped(this BinaryReader reader)
internal static object ReadTLGzipped(this BinaryReader reader, Type type)
{
using var gzipReader = new BinaryReader(new GZipStream(new MemoryStream(reader.ReadTLBytes()), CompressionMode.Decompress));
return ReadTLObject(gzipReader);
return gzipReader.ReadTLValue(type);
}
internal static bool ReadTLBool(this BinaryReader reader) => reader.ReadUInt32() switch