From d557b4fc91328f7713dd1fc35396311119bf2d1b Mon Sep 17 00:00:00 2001 From: Wizou Date: Tue, 9 Nov 2021 15:01:59 +0100 Subject: [PATCH] inheritAfter => inheritBefore (improved perf) --- src/TL.MTProto.cs | 20 +++++------ src/TL.Schema.cs | 84 +++++++++++++++++++++++------------------------ src/TL.cs | 6 ++-- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/TL.MTProto.cs b/src/TL.MTProto.cs index 2bb2d2e..d76bc16 100644 --- a/src/TL.MTProto.cs +++ b/src/TL.MTProto.cs @@ -27,17 +27,17 @@ namespace TL public Int128 server_nonce; public Int256 new_nonce; } - [TLDef(0xA9F55F95)] //p_q_inner_data_dc#a9f55f95 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 dc:int = P_Q_inner_data + [TLDef(0xA9F55F95, inheritBefore = true)] //p_q_inner_data_dc#a9f55f95 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 dc:int = P_Q_inner_data public partial class PQInnerDataDc : PQInnerData { public int dc; } - [TLDef(0x3C6A84D4)] //p_q_inner_data_temp#3c6a84d4 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 expires_in:int = P_Q_inner_data + [TLDef(0x3C6A84D4, inheritBefore = true)] //p_q_inner_data_temp#3c6a84d4 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 expires_in:int = P_Q_inner_data public partial class PQInnerDataTemp : PQInnerData { public int expires_in; } - [TLDef(0x56FDDF88)] //p_q_inner_data_temp_dc#56fddf88 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 dc:int expires_in:int = P_Q_inner_data + [TLDef(0x56FDDF88, inheritBefore = true)] //p_q_inner_data_temp_dc#56fddf88 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 dc:int expires_in:int = P_Q_inner_data public partial class PQInnerDataTempDc : PQInnerData { public int dc; @@ -59,12 +59,12 @@ namespace TL public Int128 nonce; public Int128 server_nonce; } - [TLDef(0x79CB045D)] //server_DH_params_fail#79cb045d nonce:int128 server_nonce:int128 new_nonce_hash:int128 = Server_DH_Params + [TLDef(0x79CB045D, inheritBefore = true)] //server_DH_params_fail#79cb045d nonce:int128 server_nonce:int128 new_nonce_hash:int128 = Server_DH_Params public partial class ServerDHParamsFail : ServerDHParams { public Int128 new_nonce_hash; } - [TLDef(0xD0E8075C)] //server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:bytes = Server_DH_Params + [TLDef(0xD0E8075C, inheritBefore = true)] //server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:bytes = Server_DH_Params public partial class ServerDHParamsOk : ServerDHParams { public byte[] encrypted_answer; @@ -95,17 +95,17 @@ namespace TL public Int128 nonce; public Int128 server_nonce; } - [TLDef(0x3BCBF734)] //dh_gen_ok#3bcbf734 nonce:int128 server_nonce:int128 new_nonce_hash1:int128 = Set_client_DH_params_answer + [TLDef(0x3BCBF734, inheritBefore = true)] //dh_gen_ok#3bcbf734 nonce:int128 server_nonce:int128 new_nonce_hash1:int128 = Set_client_DH_params_answer public partial class DhGenOk : SetClientDHParamsAnswer { public Int128 new_nonce_hash1; } - [TLDef(0x46DC1FB9)] //dh_gen_retry#46dc1fb9 nonce:int128 server_nonce:int128 new_nonce_hash2:int128 = Set_client_DH_params_answer + [TLDef(0x46DC1FB9, inheritBefore = true)] //dh_gen_retry#46dc1fb9 nonce:int128 server_nonce:int128 new_nonce_hash2:int128 = Set_client_DH_params_answer public partial class DhGenRetry : SetClientDHParamsAnswer { public Int128 new_nonce_hash2; } - [TLDef(0xA69DAE02)] //dh_gen_fail#a69dae02 nonce:int128 server_nonce:int128 new_nonce_hash3:int128 = Set_client_DH_params_answer + [TLDef(0xA69DAE02, inheritBefore = true)] //dh_gen_fail#a69dae02 nonce:int128 server_nonce:int128 new_nonce_hash3:int128 = Set_client_DH_params_answer public partial class DhGenFail : SetClientDHParamsAnswer { public Int128 new_nonce_hash3; @@ -134,7 +134,7 @@ namespace TL public int bad_msg_seqno; public int error_code; } - [TLDef(0xEDAB447B)] //bad_server_salt#edab447b bad_msg_id:long bad_msg_seqno:int error_code:int new_server_salt:long = BadMsgNotification + [TLDef(0xEDAB447B, inheritBefore = true)] //bad_server_salt#edab447b bad_msg_id:long bad_msg_seqno:int error_code:int new_server_salt:long = BadMsgNotification public partial class BadServerSalt : BadMsgNotification { public long new_server_salt; @@ -271,7 +271,7 @@ namespace TL public int ipv4; public int port; } - [TLDef(0x37982646)] //ipPortSecret#37982646 ipv4:int port:int secret:bytes = IpPort + [TLDef(0x37982646, inheritBefore = true)] //ipPortSecret#37982646 ipv4:int port:int secret:bytes = IpPort public partial class IpPortSecret : IpPort { public byte[] secret; diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs index 79670b2..c441a9e 100644 --- a/src/TL.Schema.cs +++ b/src/TL.Schema.cs @@ -2621,7 +2621,7 @@ namespace TL public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } /// Incomplete list of blocked users. See - [TLDef(0xE1664194, inheritAfter = true)] + [TLDef(0xE1664194)] public partial class Contacts_BlockedSlice : Contacts_Blocked { /// Total number of elements in the list @@ -2659,7 +2659,7 @@ namespace TL public override IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } /// Incomplete list of dialogs with messages and auxiliary data. See - [TLDef(0x71E094F3, inheritAfter = true)] + [TLDef(0x71E094F3)] public partial class Messages_DialogsSlice : Messages_Dialogs { /// Total number of dialogs @@ -2703,7 +2703,7 @@ namespace TL public override IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } /// Incomplete list of messages and auxiliary data. See - [TLDef(0x3A54685E, inheritAfter = true)] + [TLDef(0x3A54685E)] public partial class Messages_MessagesSlice : Messages_Messages { /// Flags, see TL conditional fields @@ -2777,7 +2777,7 @@ namespace TL public Dictionary chats; } /// Partial list of chats, more would have to be fetched with pagination See - [TLDef(0x9CD81144, inheritAfter = true)] + [TLDef(0x9CD81144)] public partial class Messages_ChatsSlice : Messages_Chats { /// Total number of results that were found server-side (not all are included in chats) @@ -2915,7 +2915,7 @@ namespace TL public SendMessageAction action; } /// The user is preparing a message in a group; typing, recording, uploading, etc. This update is valid for 6 seconds. If no repeated update received after 6 seconds, it should be considered that the user stopped doing whatever he's been doing. See - [TLDef(0x83487AF0)] + [TLDef(0x83487AF0, inheritBefore = true)] public partial class UpdateChatUserTyping : UpdateChat { /// Peer that started typing (can be the chat itself, in case of anonymous admins). @@ -3002,7 +3002,7 @@ namespace TL public DateTime date; } /// New group member. See - [TLDef(0x3DDA5451)] + [TLDef(0x3DDA5451, inheritBefore = true)] public partial class UpdateChatParticipantAdd : UpdateChat { /// ID of the new member @@ -3015,7 +3015,7 @@ namespace TL public int version; } /// A member has left the group. See - [TLDef(0xE32F3D77)] + [TLDef(0xE32F3D77, inheritBefore = true)] public partial class UpdateChatParticipantDelete : UpdateChat { /// ID of the user @@ -3193,14 +3193,14 @@ namespace TL } } /// Some messages in a supergroup/channel were deleted See - [TLDef(0xC32D5B12, inheritAfter = true)] + [TLDef(0xC32D5B12)] public partial class UpdateDeleteChannelMessages : UpdateDeleteMessages { /// Channel ID public long channel_id; } /// The view counter of a message in a channel has changed See - [TLDef(0xF226AC08)] + [TLDef(0xF226AC08, inheritBefore = true)] public partial class UpdateChannelMessageViews : UpdateChannel { /// ID of the message @@ -3209,7 +3209,7 @@ namespace TL public int views; } /// Admin permissions of a user in a legacy group were changed See - [TLDef(0xD7CA61A2)] + [TLDef(0xD7CA61A2, inheritBefore = true)] public partial class UpdateChatParticipantAdmin : UpdateChat { /// ID of the (de)admined user @@ -3400,7 +3400,7 @@ namespace TL [TLDef(0x3354678F)] public partial class UpdatePtsChanged : Update { } /// A webpage preview of a link in a channel/supergroup message was generated See - [TLDef(0x2F2BA99F, inheritAfter = true)] + [TLDef(0x2F2BA99F)] public partial class UpdateChannelWebPage : UpdateWebPage { /// Channel/supergroup ID @@ -3529,7 +3529,7 @@ namespace TL [TLDef(0xE511996D)] public partial class UpdateFavedStickers : Update { } /// The specified channel/supergroup messages were read See - [TLDef(0x44BDD535)] + [TLDef(0x44BDD535, inheritBefore = true)] public partial class UpdateChannelReadMessagesContents : UpdateChannel { /// IDs of messages that were read @@ -3539,7 +3539,7 @@ namespace TL [TLDef(0x7084A7BE)] public partial class UpdateContactsReset : Update { } /// The history of a channel/supergroup was hidden. See - [TLDef(0xB23FC698)] + [TLDef(0xB23FC698, inheritBefore = true)] public partial class UpdateChannelAvailableMessages : UpdateChannel { /// Identifier of a maximum unavailable message in a channel due to hidden history. @@ -3702,7 +3702,7 @@ namespace TL public byte[] data; } /// The forward counter of a message in a channel has changed See - [TLDef(0xD29A27F4)] + [TLDef(0xD29A27F4, inheritBefore = true)] public partial class UpdateChannelMessageForwards : UpdateChannel { /// ID of the message @@ -4317,7 +4317,7 @@ namespace TL public Dictionary users; } /// Incomplete list of photos with auxiliary data. See - [TLDef(0x15051F54, inheritAfter = true)] + [TLDef(0x15051F54)] public partial class Photos_PhotosSlice : Photos_Photos { /// Total number of photos @@ -4850,7 +4850,7 @@ namespace TL public DateTime date; } /// Message with a file enclosure sent to a protected chat See - [TLDef(0x9493FF32)] + [TLDef(0x9493FF32, inheritBefore = true)] public partial class Messages_SentEncryptedFile : Messages_SentEncryptedMessage { /// Attached file @@ -5844,7 +5844,7 @@ namespace TL public override string Text => text; } /// URL button See - [TLDef(0x258AFF05)] + [TLDef(0x258AFF05, inheritBefore = true)] public partial class KeyboardButtonUrl : KeyboardButton { /// URL @@ -5961,7 +5961,7 @@ namespace TL public override string Text => text; } /// A button that allows the user to create and send a poll when pressed; available only in private See - [TLDef(0xBBC7515D, inheritAfter = true)] + [TLDef(0xBBC7515D)] public partial class KeyboardButtonRequestPoll : KeyboardButton { /// Flags, see TL conditional fields @@ -6085,28 +6085,28 @@ namespace TL [TLDef(0x28A20571)] public partial class MessageEntityCode : MessageEntity { } /// Message entity representing a preformatted codeblock, allowing the user to specify a programming language for the codeblock. See - [TLDef(0x73924BE0)] + [TLDef(0x73924BE0, inheritBefore = true)] public partial class MessageEntityPre : MessageEntity { /// Programming language of the code public string language; } /// Message entity representing a text url: for in-text urls like https://google.com use . See - [TLDef(0x76A6D327)] + [TLDef(0x76A6D327, inheritBefore = true)] public partial class MessageEntityTextUrl : MessageEntity { /// The actual URL public string url; } /// Message entity representing a user mention: for creating a mention use . See - [TLDef(0xDC7B1140)] + [TLDef(0xDC7B1140, inheritBefore = true)] public partial class MessageEntityMentionName : MessageEntity { /// Identifier of the user that was mentioned public long user_id; } /// Message entity that can be used to create a user user mention: received mentions use the constructor, instead. See - [TLDef(0x208E68C9)] + [TLDef(0x208E68C9, inheritBefore = true)] public partial class InputMessageEntityMentionName : MessageEntity { /// Identifier of the user that was mentioned @@ -6527,7 +6527,7 @@ namespace TL public int flags; } /// A media See - [TLDef(0x3380C786)] + [TLDef(0x3380C786, inheritBefore = true)] public partial class InputBotInlineMessageMediaAuto : InputBotInlineMessage { /// Caption @@ -6546,7 +6546,7 @@ namespace TL } } /// Simple text message See - [TLDef(0x3DCD7A87)] + [TLDef(0x3DCD7A87, inheritBefore = true)] public partial class InputBotInlineMessageText : InputBotInlineMessage { /// Message @@ -6567,7 +6567,7 @@ namespace TL } } /// Geolocation See - [TLDef(0x96929A85)] + [TLDef(0x96929A85, inheritBefore = true)] public partial class InputBotInlineMessageMediaGeo : InputBotInlineMessage { /// Geolocation @@ -6594,7 +6594,7 @@ namespace TL } } /// Venue See - [TLDef(0x417BBF11)] + [TLDef(0x417BBF11, inheritBefore = true)] public partial class InputBotInlineMessageMediaVenue : InputBotInlineMessage { /// Geolocation @@ -6619,7 +6619,7 @@ namespace TL } } /// A contact See - [TLDef(0xA6EDBFFD)] + [TLDef(0xA6EDBFFD, inheritBefore = true)] public partial class InputBotInlineMessageMediaContact : InputBotInlineMessage { /// Phone number @@ -6640,7 +6640,7 @@ namespace TL } } /// A game See - [TLDef(0x4B425864)] + [TLDef(0x4B425864, inheritBefore = true)] public partial class InputBotInlineMessageGame : InputBotInlineMessage { /// Inline keyboard @@ -6653,7 +6653,7 @@ namespace TL } } /// An invoice See - [TLDef(0xD7E78225)] + [TLDef(0xD7E78225, inheritBefore = true)] public partial class InputBotInlineMessageMediaInvoice : InputBotInlineMessage { /// Product name, 1-32 characters @@ -6806,7 +6806,7 @@ namespace TL public int flags; } /// Send whatever media is attached to the See - [TLDef(0x764CF810)] + [TLDef(0x764CF810, inheritBefore = true)] public partial class BotInlineMessageMediaAuto : BotInlineMessage { /// Caption @@ -6825,7 +6825,7 @@ namespace TL } } /// Send a simple text message See - [TLDef(0x8C7F65E2)] + [TLDef(0x8C7F65E2, inheritBefore = true)] public partial class BotInlineMessageText : BotInlineMessage { /// The message @@ -6846,7 +6846,7 @@ namespace TL } } /// Send a geolocation See - [TLDef(0x051846FD)] + [TLDef(0x051846FD, inheritBefore = true)] public partial class BotInlineMessageMediaGeo : BotInlineMessage { /// Geolocation @@ -6873,7 +6873,7 @@ namespace TL } } /// Send a venue See - [TLDef(0x8A86659C)] + [TLDef(0x8A86659C, inheritBefore = true)] public partial class BotInlineMessageMediaVenue : BotInlineMessage { /// Geolocation of venue @@ -6898,7 +6898,7 @@ namespace TL } } /// Send a contact See - [TLDef(0x18D1CDC2)] + [TLDef(0x18D1CDC2, inheritBefore = true)] public partial class BotInlineMessageMediaContact : BotInlineMessage { /// Phone number @@ -6919,7 +6919,7 @@ namespace TL } } /// Send an invoice See - [TLDef(0x354A9B09)] + [TLDef(0x354A9B09, inheritBefore = true)] public partial class BotInlineMessageMediaInvoice : BotInlineMessage { /// Product name, 1-32 characters @@ -9309,28 +9309,28 @@ namespace TL [TLDef(0x46E1D13D)] public partial class RecentMeUrlUnknown : RecentMeUrl { } /// Recent t.me link to a user See - [TLDef(0xB92C09E2)] + [TLDef(0xB92C09E2, inheritBefore = true)] public partial class RecentMeUrlUser : RecentMeUrl { /// User ID public long user_id; } /// Recent t.me link to a chat See - [TLDef(0xB2DA71D2)] + [TLDef(0xB2DA71D2, inheritBefore = true)] public partial class RecentMeUrlChat : RecentMeUrl { /// Chat ID public long chat_id; } /// Recent t.me invite link to a chat See - [TLDef(0xEB49081D)] + [TLDef(0xEB49081D, inheritBefore = true)] public partial class RecentMeUrlChatInvite : RecentMeUrl { /// Chat invitation public ChatInviteBase chat_invite; } /// Recent t.me stickerset installation URL See - [TLDef(0xBC0A57DC)] + [TLDef(0xBC0A57DC, inheritBefore = true)] public partial class RecentMeUrlStickerSet : RecentMeUrl { /// Stickerset @@ -10199,14 +10199,14 @@ namespace TL public string num; } /// Ordered list of text items See - [TLDef(0x5E068047)] + [TLDef(0x5E068047, inheritBefore = true)] public partial class PageListOrderedItemText : PageListOrderedItem { /// Text public RichText text; } /// Ordered list of IV blocks See - [TLDef(0x98DD8936)] + [TLDef(0x98DD8936, inheritBefore = true)] public partial class PageListOrderedItemBlocks : PageListOrderedItem { /// Item contents @@ -12109,7 +12109,7 @@ namespace TL [TLDef(0x3FD863D1)] public partial class BotCommandScopePeerAdmins : BotCommandScopePeer { } /// The specified bot commands will be valid only for a specific user in the specified group or supergroup. See - [TLDef(0x0A1321F3)] + [TLDef(0x0A1321F3, inheritBefore = true)] public partial class BotCommandScopePeerUser : BotCommandScopePeer { /// The user diff --git a/src/TL.cs b/src/TL.cs index ce45015..92491ce 100644 --- a/src/TL.cs +++ b/src/TL.cs @@ -37,7 +37,7 @@ namespace TL var ctorNb = tlDef.CtorNb; writer.Write(ctorNb); IEnumerable fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - if (!tlDef.inheritAfter) fields = fields.GroupBy(f => f.DeclaringType).Reverse().SelectMany(g => g); + if (tlDef.inheritBefore) fields = fields.GroupBy(f => f.DeclaringType).Reverse().SelectMany(g => g); int flags = 0; IfFlagAttribute ifFlag; foreach (var field in fields) @@ -58,7 +58,7 @@ namespace TL var tlDef = type.GetCustomAttribute(); var obj = Activator.CreateInstance(type); IEnumerable fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - if (!tlDef.inheritAfter) fields = fields.GroupBy(f => f.DeclaringType).Reverse().SelectMany(g => g); + if (tlDef.inheritBefore) fields = fields.GroupBy(f => f.DeclaringType).Reverse().SelectMany(g => g); int flags = 0; IfFlagAttribute ifFlag; foreach (var field in fields) @@ -315,7 +315,7 @@ namespace TL { public readonly uint CtorNb; public TLDefAttribute(uint ctorNb) => CtorNb = ctorNb; - public bool inheritAfter; + public bool inheritBefore; } [AttributeUsage(AttributeTargets.Field)]