More class inheritance

This commit is contained in:
Wizou 2021-09-27 00:39:30 +02:00
parent e3b70fda19
commit 2ff0de667d
3 changed files with 11 additions and 23 deletions

View file

@ -80,7 +80,6 @@ namespace WTelegramClientTest
case UpdateEditMessage uem: Console.Write("(Edit): "); DisplayMessage(uem.message); break;
case UpdateDeleteChannelMessages udcm: Console.WriteLine($"{udcm.messages.Length} message(s) deleted in {AChat(udcm.channel_id)}"); break;
case UpdateDeleteMessages udm: Console.WriteLine($"{udm.messages.Length} message(s) deleted"); break;
case UpdateEditChannelMessage uecm: Console.Write("(Edit): "); DisplayMessage(uecm.message); break;
case UpdateUserTyping uut: Console.WriteLine($"{AUser(uut.user_id)} is {uut.action.GetType().Name[11..^6]}"); break;
case UpdateChatUserTyping ucut: Console.WriteLine($"{APeer(ucut.from_id)} is {ucut.action.GetType().Name[11..^6]} in {AChat(ucut.chat_id)}"); break;
case UpdateChannelUserTyping ucut2: Console.WriteLine($"{APeer(ucut2.from_id)} is {ucut2.action.GetType().Name[11..^6]} in {AChat(ucut2.channel_id)}"); break;

View file

@ -231,9 +231,8 @@ namespace WTelegram
var genericType = typeInfo.ReturnName.Length == 1 ? $"<{typeInfo.ReturnName}>" : null;
bool needNewLine = true;
int commonFields = 0;
for (int i = 0; i < typeInfo.Structs.Count; i++)
foreach (var ctor in typeInfo.Structs)
{
var ctor = typeInfo.Structs[i];
if (ctor.layer != layer) continue;
int ctorId = ctor.ID;
string className = CSharpName(ctor.predicate) + genericType;
@ -267,12 +266,12 @@ namespace WTelegram
}
else
{
for (int j = i - 1; j >= 0; j--)
foreach (var other in typeInfo.Structs)
{
var otherParams = typeInfo.Structs[j].@params;
if (other == ctor) continue;
var otherParams = other.@params;
if (otherParams.Length <= commonFields) continue;
var otherPredicate = typeInfo.Structs[j].predicate;
if (!IsDerivedName(ctor.predicate, otherPredicate)) continue;
if (!IsDerivedName(ctor.predicate, other.predicate)) continue;
if (HasPrefix(ctor, otherParams))
{
parms = ctor.@params.Skip(otherParams.Length).ToArray();
@ -283,10 +282,9 @@ namespace WTelegram
parms = ctor.@params.Take(ctor.@params.Length - otherParams.Length).ToArray();
tldefReverse = ", inheritAfter = true";
}
else continue;
commonFields = otherParams.Length;
parentClass = CSharpName(otherPredicate) + genericType;
parentClass = CSharpName(other.predicate) + genericType;
}
}
if (currentJson != "TL.MTProto")

View file

@ -1491,9 +1491,8 @@ namespace TL
}
///<summary>See <a href="https://core.telegram.org/constructor/updateChatUserTyping"/></summary>
[TLDef(0x83487AF0)]
public partial class UpdateChatUserTyping : Update
public partial class UpdateChatUserTyping : UpdateChat
{
public long chat_id;
public Peer from_id;
public SendMessageAction action;
}
@ -1552,9 +1551,8 @@ namespace TL
}
///<summary>See <a href="https://core.telegram.org/constructor/updateChatParticipantAdd"/></summary>
[TLDef(0x3DDA5451)]
public partial class UpdateChatParticipantAdd : Update
public partial class UpdateChatParticipantAdd : UpdateChat
{
public long chat_id;
public long user_id;
public long inviter_id;
public DateTime date;
@ -1562,9 +1560,8 @@ namespace TL
}
///<summary>See <a href="https://core.telegram.org/constructor/updateChatParticipantDelete"/></summary>
[TLDef(0xE32F3D77)]
public partial class UpdateChatParticipantDelete : Update
public partial class UpdateChatParticipantDelete : UpdateChat
{
public long chat_id;
public long user_id;
public int version;
}
@ -1681,9 +1678,8 @@ namespace TL
}
///<summary>See <a href="https://core.telegram.org/constructor/updateChatParticipantAdmin"/></summary>
[TLDef(0xD7CA61A2)]
public partial class UpdateChatParticipantAdmin : Update
public partial class UpdateChatParticipantAdmin : UpdateChat
{
public long chat_id;
public long user_id;
public bool is_admin;
public int version;
@ -1732,12 +1728,7 @@ namespace TL
}
///<summary>See <a href="https://core.telegram.org/constructor/updateEditChannelMessage"/></summary>
[TLDef(0x1B3F4DF7)]
public partial class UpdateEditChannelMessage : Update
{
public MessageBase message;
public int pts;
public int pts_count;
}
public partial class UpdateEditChannelMessage : UpdateEditMessage { }
///<summary>See <a href="https://core.telegram.org/constructor/updateBotCallbackQuery"/></summary>
[TLDef(0xB9CFC48D)]
public partial class UpdateBotCallbackQuery : Update