TLSharp icon indicating copy to clipboard operation
TLSharp copied to clipboard

TLDialogs vs TLDialogSlice vs TLAbsDialogs

Open barrywimlett opened this issue 5 years ago • 1 comments

For a user with alot of channels I am getting an internal error about casting TLDialogSlices to TDlialogs when doing the usual,

var dialogs = await client.GetUserDialogsAsync() as TLDialogs;

Now here is the thing:

  • GetUserDialogsAsync actually returns Task<TLAbsDialogs>

  • both TDialog and TDialogsSlice both inherit from TLAbsDialogs which is an empty abstract class.

  • TDialog and TDialogsSlice both independently implimet almost identical lists of Dialogs,Messages,Chats and Users, TDlialogSlic has one extra property 'Count' ( not that it says what it is a count of, we are left to guess )

Why not move the shared properties into TLAbsDialogs and that way 90% of users will get working code and not worry about wether they got a TDialog or a TDialogsSlice, and forcing an unneccessary and potentially incorrect cast ?

barrywimlett avatar Dec 03 '20 17:12 barrywimlett

Actually I'm going to go further most of the client methods return TLAbs classes which then have to be forcibly cast or converted to some other inherited type.

I'm intrigued to know the design reason for this as a user/consumer. I think it would help mine and hopefully others understandings of how this client works.

barrywimlett avatar Dec 03 '20 19:12 barrywimlett