Skip to content

Commit 8323199

Browse files
committed
Gen,TL: Transport layer rewrite [1/2]
- add response type as generic
1 parent 400b9c1 commit 8323199

335 files changed

Lines changed: 993 additions & 1032 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/TgSharp.Generator/Method.tmp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace /* NAMESPACE */
3838
/* SERIALIZE */
3939
}
4040

41-
public override void DeserializeResponse(BinaryReader br)
41+
protected override void DeserializeResponse(BinaryReader br)
4242
{
4343
/* DESERIALIZEResp */
4444
}

src/TgSharp.Generator/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ static void Main(string[] args)
260260
if (nspace.EndsWith("."))
261261
nspace = nspace.Remove(nspace.Length - 1, 1);
262262
string temp = methodStyle.Replace("/* NAMESPACE */", rootNamespace + "." + nspace);
263-
temp = temp.Replace("/* PARENT */", "TLMethod");
263+
var methodResponseType = CheckForFlagBase(c.Type, GetTypeName(c.Type)) ;
264+
temp = temp.Replace("/* PARENT */", $"TLMethod<{methodResponseType}>");
264265
temp = temp.Replace("/*Constructor*/", c.Id.ToString());
265266
temp = temp.Replace("/* NAME */", GetNameofClass(c.Method, false, true));
266267
#endregion
@@ -281,7 +282,6 @@ static void Main(string[] args)
281282
} else {
282283
first = false;
283284
}
284-
fields += $"public {CheckForFlagBase(c.Type, GetTypeName(c.Type))} Response" + " { get; set; }";
285285
temp = temp.Replace("/* PARAMS */", fields);
286286
#endregion
287287
#region ComputeFlagFunc

src/TgSharp.TL/TL/Account/TLRequestAcceptAuthorization.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace TgSharp.TL.Account
1111
{
1212
[TLObject(-419267436)]
13-
public class TLRequestAcceptAuthorization : TLMethod
13+
public class TLRequestAcceptAuthorization : TLMethod<bool>
1414
{
1515
public override int Constructor
1616
{
@@ -25,7 +25,7 @@ public override int Constructor
2525
public string PublicKey { get; set; }
2626
public TLVector<TLSecureValueHash> ValueHashes { get; set; }
2727
public TLSecureCredentialsEncrypted Credentials { get; set; }
28-
public bool Response { get; set; }
28+
2929

3030
public void ComputeFlags()
3131
{
@@ -51,7 +51,7 @@ public override void SerializeBody(BinaryWriter bw)
5151
ObjectUtils.SerializeObject(Credentials, bw);
5252
}
5353

54-
public override void DeserializeResponse(BinaryReader br)
54+
protected override void DeserializeResponse(BinaryReader br)
5555
{
5656
Response = BoolUtil.Deserialize(br);
5757
}

src/TgSharp.TL/TL/Account/TLRequestCancelPasswordEmail.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace TgSharp.TL.Account
1111
{
1212
[TLObject(-1043606090)]
13-
public class TLRequestCancelPasswordEmail : TLMethod
13+
public class TLRequestCancelPasswordEmail : TLMethod<bool>
1414
{
1515
public override int Constructor
1616
{
@@ -20,7 +20,7 @@ public override int Constructor
2020
}
2121
}
2222

23-
public bool Response { get; set; }
23+
2424

2525
public void ComputeFlags()
2626
{
@@ -38,7 +38,7 @@ public override void SerializeBody(BinaryWriter bw)
3838
// do nothing else
3939
}
4040

41-
public override void DeserializeResponse(BinaryReader br)
41+
protected override void DeserializeResponse(BinaryReader br)
4242
{
4343
Response = BoolUtil.Deserialize(br);
4444
}

src/TgSharp.TL/TL/Account/TLRequestChangePhone.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace TgSharp.TL.Account
1111
{
1212
[TLObject(1891839707)]
13-
public class TLRequestChangePhone : TLMethod
13+
public class TLRequestChangePhone : TLMethod<TLAbsUser>
1414
{
1515
public override int Constructor
1616
{
@@ -23,7 +23,7 @@ public override int Constructor
2323
public string PhoneNumber { get; set; }
2424
public string PhoneCodeHash { get; set; }
2525
public string PhoneCode { get; set; }
26-
public TLAbsUser Response { get; set; }
26+
2727

2828
public void ComputeFlags()
2929
{
@@ -45,7 +45,7 @@ public override void SerializeBody(BinaryWriter bw)
4545
StringUtil.Serialize(PhoneCode, bw);
4646
}
4747

48-
public override void DeserializeResponse(BinaryReader br)
48+
protected override void DeserializeResponse(BinaryReader br)
4949
{
5050
Response = (TLAbsUser)ObjectUtils.DeserializeObject(br);
5151
}

src/TgSharp.TL/TL/Account/TLRequestCheckUsername.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace TgSharp.TL.Account
1111
{
1212
[TLObject(655677548)]
13-
public class TLRequestCheckUsername : TLMethod
13+
public class TLRequestCheckUsername : TLMethod<bool>
1414
{
1515
public override int Constructor
1616
{
@@ -21,7 +21,7 @@ public override int Constructor
2121
}
2222

2323
public string Username { get; set; }
24-
public bool Response { get; set; }
24+
2525

2626
public void ComputeFlags()
2727
{
@@ -39,7 +39,7 @@ public override void SerializeBody(BinaryWriter bw)
3939
StringUtil.Serialize(Username, bw);
4040
}
4141

42-
public override void DeserializeResponse(BinaryReader br)
42+
protected override void DeserializeResponse(BinaryReader br)
4343
{
4444
Response = BoolUtil.Deserialize(br);
4545
}

src/TgSharp.TL/TL/Account/TLRequestConfirmPasswordEmail.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace TgSharp.TL.Account
1111
{
1212
[TLObject(-1881204448)]
13-
public class TLRequestConfirmPasswordEmail : TLMethod
13+
public class TLRequestConfirmPasswordEmail : TLMethod<bool>
1414
{
1515
public override int Constructor
1616
{
@@ -21,7 +21,7 @@ public override int Constructor
2121
}
2222

2323
public string Code { get; set; }
24-
public bool Response { get; set; }
24+
2525

2626
public void ComputeFlags()
2727
{
@@ -39,7 +39,7 @@ public override void SerializeBody(BinaryWriter bw)
3939
StringUtil.Serialize(Code, bw);
4040
}
4141

42-
public override void DeserializeResponse(BinaryReader br)
42+
protected override void DeserializeResponse(BinaryReader br)
4343
{
4444
Response = BoolUtil.Deserialize(br);
4545
}

src/TgSharp.TL/TL/Account/TLRequestConfirmPhone.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace TgSharp.TL.Account
1111
{
1212
[TLObject(1596029123)]
13-
public class TLRequestConfirmPhone : TLMethod
13+
public class TLRequestConfirmPhone : TLMethod<bool>
1414
{
1515
public override int Constructor
1616
{
@@ -22,7 +22,7 @@ public override int Constructor
2222

2323
public string PhoneCodeHash { get; set; }
2424
public string PhoneCode { get; set; }
25-
public bool Response { get; set; }
25+
2626

2727
public void ComputeFlags()
2828
{
@@ -42,7 +42,7 @@ public override void SerializeBody(BinaryWriter bw)
4242
StringUtil.Serialize(PhoneCode, bw);
4343
}
4444

45-
public override void DeserializeResponse(BinaryReader br)
45+
protected override void DeserializeResponse(BinaryReader br)
4646
{
4747
Response = BoolUtil.Deserialize(br);
4848
}

src/TgSharp.TL/TL/Account/TLRequestCreateTheme.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace TgSharp.TL.Account
1111
{
1212
[TLObject(-2077048289)]
13-
public class TLRequestCreateTheme : TLMethod
13+
public class TLRequestCreateTheme : TLMethod<TLTheme>
1414
{
1515
public override int Constructor
1616
{
@@ -25,7 +25,7 @@ public override int Constructor
2525
public string Title { get; set; }
2626
public TLAbsInputDocument Document { get; set; }
2727
public TLInputThemeSettings Settings { get; set; }
28-
public TLTheme Response { get; set; }
28+
2929

3030
public void ComputeFlags()
3131
{
@@ -61,7 +61,7 @@ public override void SerializeBody(BinaryWriter bw)
6161
ObjectUtils.SerializeObject(Settings, bw);
6262
}
6363

64-
public override void DeserializeResponse(BinaryReader br)
64+
protected override void DeserializeResponse(BinaryReader br)
6565
{
6666
Response = (TLTheme)ObjectUtils.DeserializeObject(br);
6767
}

src/TgSharp.TL/TL/Account/TLRequestDeleteAccount.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace TgSharp.TL.Account
1111
{
1212
[TLObject(1099779595)]
13-
public class TLRequestDeleteAccount : TLMethod
13+
public class TLRequestDeleteAccount : TLMethod<bool>
1414
{
1515
public override int Constructor
1616
{
@@ -21,7 +21,7 @@ public override int Constructor
2121
}
2222

2323
public string Reason { get; set; }
24-
public bool Response { get; set; }
24+
2525

2626
public void ComputeFlags()
2727
{
@@ -39,7 +39,7 @@ public override void SerializeBody(BinaryWriter bw)
3939
StringUtil.Serialize(Reason, bw);
4040
}
4141

42-
public override void DeserializeResponse(BinaryReader br)
42+
protected override void DeserializeResponse(BinaryReader br)
4343
{
4444
Response = BoolUtil.Deserialize(br);
4545
}

0 commit comments

Comments
 (0)