ilyalatt / Telega

C# Telegram MTProto Client
https://ilyalatt.github.io/Telega/
MIT License
58 stars 15 forks source link

LanguageExt incompatible to iOS #64

Closed maxbartunik closed 3 years ago

maxbartunik commented 3 years ago

Using Telega in a Xamarin.iOS project produces following exception when calling TelegramClient.Connect():

Telega internal exception. Unhandled exception. See an inner exception. at Telega.TaskWrapper.Wrap[T] (System.Func`1[TResult] wrapper) at Telega.Connect.TgBellhop.Connect (Microsoft.Extensions.Logging.ILogger logger, Telega.Connect.ConnectInfo connectInfo, Telega.CallMiddleware.TgCallMiddlewareChain callMiddlewareChain, Telega.Connect.TcpClientConnectionHandler connHandler) at Telega.Client.TelegramClient.Connect (Telega.Connect.ConnectInfo connectInfo, Telega.ISessionStore store, Telega.CallMiddleware.TgCallMiddlewareChain callMiddlewareChain, Telega.Connect.TcpClientConnectionHandler tcpClientConnectionHandler, Microsoft.Extensions.Logging.ILogger logger) at Telega.Client.TelegramClient.Connect (System.Int32 apiId, Telega.ISessionStore store, System.Net.IPEndPoint endpoint, Telega.CallMiddleware.TgCallMiddlewareChain callMiddlewareChain, Telega.Connect.TcpClientConnectionHandler tcpClientConnectionHandler)

Inner exception: {System.PlatformNotSupportedException} The type initializer for 'LanguageExt.Range3' threw an exception. at LanguageExt.Prelude.Range (System.Int32 from, System.Int32 count, System.Int32 step) at Telega.Rpc.TgSystemMessageHandler.ReadContainer (System.IO.BinaryReader br) at Telega.Rpc.TgSystemMessageHandler+<>c__DisplayClass15_0.<Handle>b__0 (Telega.Rpc.TgSystemMessageHandler+Message message) at (wrapper delegate-invoke) System.Func2[Telega.Rpc.TgSystemMessageHandler+Message,LanguageExt.Unit].invoke_TResult_T(Telega.Rpc.TgSystemMessageHandler/Message) at LanguageExt.CondExt.Apply[A,B] (A a, System.Func2[T,TResult] f) at Telega.Rpc.TgTransport.ReceiveLoopImpl (Microsoft.Extensions.Logging.ILogger logger) at Telega.Rpc.TgTransport.ReceiveLoop (Microsoft.Extensions.Logging.ILogger logger) at Telega.Rpc.TgTransport+<>c__DisplayClass19_01[T].gCheckReceiveLoop|0 () at Telega.Rpc.TgTransport+<>cDisplayClass19_11[T].<Call>g__AwaitResult|1 () at Telega.CallMiddleware.FloodMiddleware+<>c__DisplayClass1_11[T].g__ReceiveWrapper|1 () at Telega.CallMiddleware.TgCustomizedTransport.Call[T] (Telega.Rpc.Dto.ITgFunc1[TRes] func) at Telega.Connect.TgConnectionEstablisher.EstablishConnection (Microsoft.Extensions.Logging.ILogger logger, Telega.Connect.ConnectInfo connectInfo, Telega.CallMiddleware.TgCallMiddlewareChain callMiddlewareChain, Telega.Connect.TcpClientConnectionHandler connHandler) at Telega.TaskWrapper.Wrap[T] (System.Func1[TResult] wrapper)

This is due to the use of System.Reflection.Emit in LanguageExt (which is not supported on iOS: https://docs.microsoft.com/en-us/xamarin/ios/internals/limitations).

maxbartunik commented 3 years ago

I have become a fan of Telega and would be very happy for a solution...

maxbartunik commented 3 years ago

Issue opened in LanguageExt: https://github.com/louthy/language-ext/issues/887

ilyalatt commented 3 years ago

Hello. The easy way is to use fixed LanguageExt version. However Telega moves away from LanguageExt because it adds too much complexity for basic things. See this comment and the roadmap. You can try simplified version 0.5.0-preview001 without LanguageExt.

maxbartunik commented 3 years ago

The above error occured in 0.5.0-preview001. However, I could not track down the link to LanguageExt in this repo. Perhaps a faulty nuget package? LanguageExt is listed as a dependency in the 0.5.0-preview001 package...

maxbartunik commented 3 years ago

Using LanguageExt v3.5.30-beta resolves the issue.

ilyalatt commented 3 years ago

Looks like a staled package. I've pushed 0.5.0-preview002 with the latest master.