From a54cc9261844eb49102adea6cf7660a34bace0ec Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Sun, 27 Mar 2022 22:26:57 +0200 Subject: [PATCH] ctor for Input User/Channel with mandatory access_hash parameter --- src/TL.Helpers.cs | 5 +++++ src/TL.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs index a7e42fe..22f6caf 100644 --- a/src/TL.Helpers.cs +++ b/src/TL.Helpers.cs @@ -20,12 +20,14 @@ namespace TL /// ⚠ Only for small private Chat. Chat groups of type Channel must use InputPeerChannel. See Terminology in README /// Chat identifier public InputPeerChat(long chat_id) => this.chat_id = chat_id; + internal InputPeerChat() { } } partial class InputPeerUser { /// User identifier /// REQUIRED FIELD. See FAQ for how to obtain it
access_hash value from the constructor public InputPeerUser(long user_id, long access_hash) { this.user_id = user_id; this.access_hash = access_hash; } + internal InputPeerUser() { } public static implicit operator InputUser(InputPeerUser user) => new(user.user_id, user.access_hash); } partial class InputPeerChannel @@ -33,6 +35,7 @@ namespace TL /// Channel identifier /// REQUIRED FIELD. See FAQ for how to obtain it
access_hash value from the constructor public InputPeerChannel(long channel_id, long access_hash) { this.channel_id = channel_id; this.access_hash = access_hash; } + internal InputPeerChannel() { } public static implicit operator InputChannel(InputPeerChannel channel) => new(channel.channel_id, channel.access_hash); } @@ -46,6 +49,7 @@ namespace TL /// User identifier /// REQUIRED FIELD. See FAQ for how to obtain it
access_hash value from the constructor public InputUser(long user_id, long access_hash) { this.user_id = user_id; this.access_hash = access_hash; } + internal InputUser() { } public static implicit operator InputPeerUser(InputUser user) => new(user.user_id, user.access_hash); } @@ -421,6 +425,7 @@ namespace TL /// Channel identifier /// REQUIRED FIELD. See FAQ for how to obtain it
access_hash value from the constructor public InputChannel(long channel_id, long access_hash) { this.channel_id = channel_id; this.access_hash = access_hash; } + internal InputChannel() { } public static implicit operator InputPeerChannel(InputChannel channel) => new(channel.channel_id, channel.access_hash); } diff --git a/src/TL.cs b/src/TL.cs index 9a91890..de23415 100644 --- a/src/TL.cs +++ b/src/TL.cs @@ -78,7 +78,7 @@ namespace TL throw new ApplicationException($"Cannot find type for ctor #{ctorNb:x}"); if (type == null) return null; // nullable ctor (class meaning is associated with null) var tlDef = type.GetCustomAttribute(); - var obj = Activator.CreateInstance(type); + var obj = Activator.CreateInstance(type, true); IEnumerable fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (tlDef.inheritBefore) fields = fields.GroupBy(f => f.DeclaringType).Reverse().SelectMany(g => g); uint flags = 0;