Skip to content

updateChatMessageTtl is not implemented and resulted in exception thrown #167

@DamienLaw

Description

@DamienLaw

updateChatMessageTtl is not implemented and when received from Telegram will result in an exception thrown.

Could not create an instance of type TdLib.TdApi+Object. Type is an interface or abstract class and cannot be instantiated. Path '@type', line 1, position 9.

private void ProcessEvents()
{
var ct = _cts.Token;
while (!ct.IsCancellationRequested)
{
var data = _tdJsonClient.Receive(0.1);
if (!string.IsNullOrEmpty(data))
{
try
{
var structure = JsonConvert.DeserializeObject<TdApi.Object>(data, _converter);
Received?.Invoke(this, structure);
if (structure is TdApi.Update.UpdateAuthorizationState update)
{
AuthorizationStateChanged?.Invoke(this, update.AuthorizationState);
}
}
catch (Exception e)
{
ExceptionThrown?.Invoke(this, e);
}
}
}
}

This is because on line 54, the deserialization will fallback to TdApi.Object if the type is not found.

public abstract class Object
{
[JsonProperty("@type")] public virtual string DataType { get; set; }
[JsonProperty("@extra")] public virtual string Extra { get; set; }
}

And TdApi.Object is abstract. No deserialization can be performed on abstract class.

Metadata

Metadata

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions