mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
[rollback] Use records for TL methods
It was a nice idea and it worked but it made the lib 3x larger just for sugar syntax in generated code
This commit is contained in:
parent
9e4d67ed86
commit
30f20fad0e
|
|
@ -261,11 +261,17 @@ namespace WTelegram
|
|||
|
||||
var keepAliveTask = KeepAlive(_cts.Token);
|
||||
TLConfig = await this.InvokeWithLayer(Layer.Version,
|
||||
new Schema.InitConnection_<Config>(0, _apiId,
|
||||
Config("device_model"), Config("system_version"), Config("app_version"),
|
||||
Config("system_lang_code"), Config("lang_pack"), Config("lang_code"),
|
||||
null, null, new Schema.Help_GetConfig_()
|
||||
));
|
||||
new Schema.InitConnection_<Config>
|
||||
{
|
||||
api_id = _apiId,
|
||||
device_model = Config("device_model"),
|
||||
system_version = Config("system_version"),
|
||||
app_version = Config("app_version"),
|
||||
system_lang_code = Config("system_lang_code"),
|
||||
lang_pack = Config("lang_pack"),
|
||||
lang_code = Config("lang_code"),
|
||||
query = new Schema.Help_GetConfig_()
|
||||
});
|
||||
_session.DcOptions = TLConfig.dc_options;
|
||||
_saltChangeCounter = 0;
|
||||
if (_dcSession.DataCenter == null)
|
||||
|
|
|
|||
|
|
@ -294,58 +294,129 @@ namespace TL
|
|||
}
|
||||
|
||||
// ---functions---
|
||||
#pragma warning disable IDE1006
|
||||
|
||||
public static class MTProto
|
||||
{
|
||||
[TLDef(0x60469778)]
|
||||
public record ReqPq_(Int128 nonce) : IMethod<ResPQ>;
|
||||
[TLDef(0x60469778)] //req_pq#60469778 nonce:int128 = ResPQ
|
||||
public partial class ReqPq_ : IMethod<ResPQ>
|
||||
{
|
||||
public Int128 nonce;
|
||||
}
|
||||
public static Task<ResPQ> ReqPq(this Client client, Int128 nonce)
|
||||
=> client.CallBareAsync(new ReqPq_(nonce));
|
||||
=> client.CallBareAsync(new ReqPq_
|
||||
{
|
||||
nonce = nonce,
|
||||
});
|
||||
|
||||
[TLDef(0xBE7E8EF1)]
|
||||
public record ReqPqMulti_(Int128 nonce) : IMethod<ResPQ>;
|
||||
[TLDef(0xBE7E8EF1)] //req_pq_multi#be7e8ef1 nonce:int128 = ResPQ
|
||||
public partial class ReqPqMulti_ : IMethod<ResPQ>
|
||||
{
|
||||
public Int128 nonce;
|
||||
}
|
||||
public static Task<ResPQ> ReqPqMulti(this Client client, Int128 nonce)
|
||||
=> client.CallBareAsync(new ReqPqMulti_(nonce));
|
||||
=> client.CallBareAsync(new ReqPqMulti_
|
||||
{
|
||||
nonce = nonce,
|
||||
});
|
||||
|
||||
[TLDef(0xD712E4BE)]
|
||||
public record ReqDHParams_(Int128 nonce, Int128 server_nonce, byte[] p, byte[] q, long public_key_fingerprint, byte[] encrypted_data) : IMethod<ServerDHParams>;
|
||||
[TLDef(0xD712E4BE)] //req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:bytes q:bytes public_key_fingerprint:long encrypted_data:bytes = Server_DH_Params
|
||||
public partial class ReqDHParams_ : IMethod<ServerDHParams>
|
||||
{
|
||||
public Int128 nonce;
|
||||
public Int128 server_nonce;
|
||||
public byte[] p;
|
||||
public byte[] q;
|
||||
public long public_key_fingerprint;
|
||||
public byte[] encrypted_data;
|
||||
}
|
||||
public static Task<ServerDHParams> ReqDHParams(this Client client, Int128 nonce, Int128 server_nonce, byte[] p, byte[] q, long public_key_fingerprint, byte[] encrypted_data)
|
||||
=> client.CallBareAsync(new ReqDHParams_(nonce, server_nonce, p, q, public_key_fingerprint, encrypted_data));
|
||||
=> client.CallBareAsync(new ReqDHParams_
|
||||
{
|
||||
nonce = nonce,
|
||||
server_nonce = server_nonce,
|
||||
p = p,
|
||||
q = q,
|
||||
public_key_fingerprint = public_key_fingerprint,
|
||||
encrypted_data = encrypted_data,
|
||||
});
|
||||
|
||||
[TLDef(0xF5045F1F)]
|
||||
public record SetClientDHParams_(Int128 nonce, Int128 server_nonce, byte[] encrypted_data) : IMethod<SetClientDHParamsAnswer>;
|
||||
[TLDef(0xF5045F1F)] //set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:bytes = Set_client_DH_params_answer
|
||||
public partial class SetClientDHParams_ : IMethod<SetClientDHParamsAnswer>
|
||||
{
|
||||
public Int128 nonce;
|
||||
public Int128 server_nonce;
|
||||
public byte[] encrypted_data;
|
||||
}
|
||||
public static Task<SetClientDHParamsAnswer> SetClientDHParams(this Client client, Int128 nonce, Int128 server_nonce, byte[] encrypted_data)
|
||||
=> client.CallBareAsync(new SetClientDHParams_(nonce, server_nonce, encrypted_data));
|
||||
=> client.CallBareAsync(new SetClientDHParams_
|
||||
{
|
||||
nonce = nonce,
|
||||
server_nonce = server_nonce,
|
||||
encrypted_data = encrypted_data,
|
||||
});
|
||||
|
||||
[TLDef(0xD1435160)]
|
||||
public record DestroyAuthKey_() : IMethod<DestroyAuthKeyRes>;
|
||||
[TLDef(0xD1435160)] //destroy_auth_key#d1435160 = DestroyAuthKeyRes
|
||||
public partial class DestroyAuthKey_ : IMethod<DestroyAuthKeyRes> { }
|
||||
public static Task<DestroyAuthKeyRes> DestroyAuthKey(this Client client)
|
||||
=> client.CallBareAsync(new DestroyAuthKey_());
|
||||
=> client.CallBareAsync(new DestroyAuthKey_
|
||||
{
|
||||
});
|
||||
|
||||
[TLDef(0x58E4A740)]
|
||||
public record RpcDropAnswer_(long req_msg_id) : IMethod<RpcDropAnswer>;
|
||||
[TLDef(0x58E4A740)] //rpc_drop_answer#58e4a740 req_msg_id:long = RpcDropAnswer
|
||||
public partial class RpcDropAnswer_ : IMethod<RpcDropAnswer>
|
||||
{
|
||||
public long req_msg_id;
|
||||
}
|
||||
public static Task<RpcDropAnswer> RpcDropAnswer(this Client client, long req_msg_id)
|
||||
=> client.CallBareAsync(new RpcDropAnswer_(req_msg_id));
|
||||
=> client.CallBareAsync(new RpcDropAnswer_
|
||||
{
|
||||
req_msg_id = req_msg_id,
|
||||
});
|
||||
|
||||
[TLDef(0xB921BD04)]
|
||||
public record GetFutureSalts_(int num) : IMethod<FutureSalts>;
|
||||
[TLDef(0xB921BD04)] //get_future_salts#b921bd04 num:int = FutureSalts
|
||||
public partial class GetFutureSalts_ : IMethod<FutureSalts>
|
||||
{
|
||||
public int num;
|
||||
}
|
||||
public static Task<FutureSalts> GetFutureSalts(this Client client, int num)
|
||||
=> client.CallAsync(new GetFutureSalts_(num));
|
||||
=> client.CallAsync(new GetFutureSalts_
|
||||
{
|
||||
num = num,
|
||||
});
|
||||
|
||||
[TLDef(0x7ABE77EC)]
|
||||
public record Ping_(long ping_id) : IMethod<Pong>;
|
||||
[TLDef(0x7ABE77EC)] //ping#7abe77ec ping_id:long = Pong
|
||||
public partial class Ping_ : IMethod<Pong>
|
||||
{
|
||||
public long ping_id;
|
||||
}
|
||||
public static Task<Pong> Ping(this Client client, long ping_id)
|
||||
=> client.CallAsync(new Ping_(ping_id));
|
||||
=> client.CallAsync(new Ping_
|
||||
{
|
||||
ping_id = ping_id,
|
||||
});
|
||||
|
||||
[TLDef(0xF3427B8C)]
|
||||
public record PingDelayDisconnect_(long ping_id, int disconnect_delay) : IMethod<Pong>;
|
||||
[TLDef(0xF3427B8C)] //ping_delay_disconnect#f3427b8c ping_id:long disconnect_delay:int = Pong
|
||||
public partial class PingDelayDisconnect_ : IMethod<Pong>
|
||||
{
|
||||
public long ping_id;
|
||||
public int disconnect_delay;
|
||||
}
|
||||
public static Task<Pong> PingDelayDisconnect(this Client client, long ping_id, int disconnect_delay)
|
||||
=> client.CallAsync(new PingDelayDisconnect_(ping_id, disconnect_delay));
|
||||
=> client.CallAsync(new PingDelayDisconnect_
|
||||
{
|
||||
ping_id = ping_id,
|
||||
disconnect_delay = disconnect_delay,
|
||||
});
|
||||
|
||||
[TLDef(0xE7512126)]
|
||||
public record DestroySession_(long session_id) : IMethod<DestroySessionRes>;
|
||||
[TLDef(0xE7512126)] //destroy_session#e7512126 session_id:long = DestroySessionRes
|
||||
public partial class DestroySession_ : IMethod<DestroySessionRes>
|
||||
{
|
||||
public long session_id;
|
||||
}
|
||||
public static Task<DestroySessionRes> DestroySession(this Client client, long session_id)
|
||||
=> client.CallBareAsync(new DestroySession_(session_id));
|
||||
=> client.CallBareAsync(new DestroySession_
|
||||
{
|
||||
session_id = session_id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
5704
src/TL.Schema.cs
5704
src/TL.Schema.cs
File diff suppressed because it is too large
Load diff
|
|
@ -46,7 +46,7 @@ namespace TL
|
|||
if (((ifFlag = field.GetCustomAttribute<IfFlagAttribute>()) != null) && (flags & (1 << ifFlag.Bit)) == 0) continue;
|
||||
object value = field.GetValue(obj);
|
||||
writer.WriteTLValue(value, field.FieldType);
|
||||
if (field.Name == "flags" || field.Name == "<flags>k__BackingField") flags = (int)value;
|
||||
if (field.Name == "flags") flags = (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ namespace TL
|
|||
if (((ifFlag = field.GetCustomAttribute<IfFlagAttribute>()) != null) && (flags & (1 << ifFlag.Bit)) == 0) continue;
|
||||
object value = reader.ReadTLValue(field.FieldType);
|
||||
field.SetValue(obj, value);
|
||||
if (field.Name == "flags" || field.Name == "<flags>k__BackingField") flags = (int)value;
|
||||
if (field.Name == "flags") flags = (int)value;
|
||||
else if (field.Name == "access_hash") reader.Client?.UpdateAccessHash(obj, type, value);
|
||||
}
|
||||
return type == typeof(GzipPacked) ? UnzipPacket((GzipPacked)obj, reader.Client) : (IObject)obj;
|
||||
|
|
|
|||
Loading…
Reference in a new issue