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 // 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 var dialogs = await Client.Messages_GetAllDialogs(); // dialogs = groups/channels/users
dialogs.CollectUsersChats(Manager.Users, Manager.Chats); dialogs.CollectUsersChats(Manager.Users, Manager.Chats);
Console.ReadKey(); 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) //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; continue;
} }
if (id == 0x3072CFA1) // GzipPacked 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")) else if (name != "Null" && (ns != "TL.Methods" || name == "Ping"))
makeTL.AppendLine($"\t\t\t0x{id:X8} => new {(ns == "TL" ? "" : ns + '.')}{name}().ReadTL(reader),"); makeTL.AppendLine($"\t\t\t0x{id:X8} => new {(ns == "TL" ? "" : ns + '.')}{name}().ReadTL(reader),");
var override_ = symbol.BaseType == object_ ? "" : "override "; var override_ = symbol.BaseType == object_ ? "" : "override ";

View file

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

View file

@ -350,10 +350,10 @@ namespace TL
writer.Write(0); // null arrays/strings are serialized as empty 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)); 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 internal static bool ReadTLBool(this BinaryReader reader) => reader.ReadUInt32() switch