2

I am using tl-language compiler to compile schema of Telegram Api TL language described in https://core.telegram.org/mtproto in C#

There is a compiler that compile tl-language to C# classes https://github.com/everbytes/SharpTL.Compiler

But it can compile new telegram schema at this line:

"params":[
    {"name":"flags","type":"#"},
    {"name":"report_spam","type":"flags.0?true"}]
,"type":"PeerSettings"}

And it compile it to wrong code:

[TLObject(0x818426CD)]
public partial class PeerSettings : IPeerSettings
{
    [TLProperty(1)]
    public I# Flags { get; set; }

    [TLProperty(2)]
    public IFlags0?true ReportSpam { get; set; }

}

Is there any solution in casting in C# codes?

I do not know what is type of this "flags:#" in C#

This type "#" described in https://core.telegram.org/mtproto/TL-formal

user {flags:#} id:flags.0?string first_name:flags.1?string last_name:flags.2?string reserved3:flags.3?False reserved4:flags.4?False = User flags;

In the future, bits 3 and 4 in the flags field may be used to transmit new fields after changing the names and types of the reserved3 and reserved4 fields

Preshan Pradeepa
  • 698
  • 14
  • 31
Mahdi
  • 649
  • 8
  • 18
  • It seems like the property is an enumerable of IFlags: "public IFlags { get; set; }" given "#" seems to define the set of IFlag types/values. – Ryan Peters May 25 '16 at 10:27
  • flag# is integer type used as a flag to indicate which flagged-fields are present (on receiving) or which flagged-fields you are including(on sending) – Charles Okwuagwu Jun 16 '16 at 07:29

2 Answers2

1

this means int according to TLGenerator

Hamed Zakery Miab
  • 738
  • 2
  • 12
  • 34
1
peerSettings#818426cd flags:# report_spam:flags.0?true = PeerSettings  

deep searching around this I think this hash (#) means that dynamic value of variable, in some cases it can be true or false, another cases it can be a sequence of integers nonnegative:

matrix {X:Type} m:# n:# a:(%Tuple (%Tuple X m) n) = Matrix X;

above we got the M and N taking a integer random value > 0

get_users req_fields:# ids:%(Vector int) = Vector %(User req_fields)

in this another case it can assume a conditional value
req_fields variable is cast only to User object, but in other cases it could be casted
to another kind of object.

maybe the correct way of this TLObject in c# is :

[TLObject(0x818426CD)]
public partial class PeerSettings : IPeerSettings
{
    [TLProperty(1)]
    public int Flags { get; set; }

    [TLProperty(2)]
    public bool ReportSpam { get; set; }

}

apologises my english is rusty

Arthur Melo
  • 454
  • 5
  • 13