Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# implementation #27

Closed
mostafa8026 opened this issue Feb 2, 2018 · 26 comments
Closed

C# implementation #27

mostafa8026 opened this issue Feb 2, 2018 · 26 comments

Comments

@mostafa8026
Copy link

Do you have any schedule for C# interface?
If it does not publish in this month, could u please guide us through implementing our own C# interface?

@mostafa8026
Copy link
Author

I wrote a sample code in this commit, But I don't know it works fine in this way or not!

@x2bool
Copy link

x2bool commented Feb 16, 2018

C# binding (will be released soon)

When? Is there any schedule?

@levlam
Copy link
Contributor

levlam commented Feb 16, 2018

We currently testing it in different environments. It is likely to be released till the end of the month.

@Anonymphous
Copy link

@levlam Will it be compatible with .NET Core 2.0?

@levlam
Copy link
Contributor

levlam commented Feb 19, 2018

@Anonymphous, No. .NET Core 2.0 lacks support of using native C++-code directly, so TDLib can be used there only as a shared library. TDLib JSON interface is perfectly suitable for that usage, but intermediate conversion to/from JSON will be required.

@alizx
Copy link

alizx commented Feb 26, 2018

@levlam according to docs/standard/native-interop.md dotnet core supports P/Invoke if I'm not wrong isn't that the way people write bindings?
can you please elaborate on this? I want to know is the possibility to use TDLib in Linux using C#?

@x2bool
Copy link

x2bool commented Feb 26, 2018

@alizx it's probably about C++/CLI support: https://github.com/dotnet/coreclr/issues/659

@levlam Will it be compatible with Mono?

@levlam
Copy link
Contributor

levlam commented Feb 26, 2018

P/Invoke is a very convenient way to call С code from a shared library from C#, but this is not enough to be able to pass C++ and C# objects between C and C# code. We will provide C++/CLI / C++/CX interface which provides a way to communicate with TDLib using C# objects, which isn't supported in .NET Core.
But TDLib anyway can be used through P/Invoke without any additional interface. TDLib JSON interface is created exactly for this purpose.

@levlam
Copy link
Contributor

levlam commented Feb 26, 2018

@x2bool It looks like Mono also doesn't support C++/CLI unless it is used under Windows (or unless Windows version of Mono is used using Wine).

@hadi77ir
Copy link

hadi77ir commented Mar 2, 2018

There's CppSharp which helps in interoperability between C# and C++ libraries. As an example, QtSharp (C#/.NET bindings for Qt) is implemented with CppSharp.

@levlam
Copy link
Contributor

levlam commented Mar 2, 2018

@hadi77ir We haven't tried it, but I doubt that it will be able to generate bindings which will be more convenient or more efficient than TDLib JSON interface. Nevertheless, it would be interesting to see what can be generated using CppSharp.

@isopen
Copy link
Contributor

isopen commented Mar 4, 2018

@levlam Most likely, as you say. But this will need to be checked.
One thing I can say for sure at this time: cppsharp does not start with a pleasant.
https://github.com/mono/CppSharp/blob/master/docs/GettingStarted.md
Only one threshold of entry into it already speaks for itself.

@OleksiyMoroz
Copy link

So we will not ably to use TDLib with .net core 2 anyway?

@isopen
Copy link
Contributor

isopen commented Mar 5, 2018

@levlam
Copy link
Contributor

levlam commented Mar 5, 2018

@OleksiyMoroz You will not be able to use C++/CLI / C++/CX native TDLib interface with .Net Core, but you are able to use TDLib JSON interface.

It is also possible to generate converters between TDLib JSON objects and C# classes to simplify usage of JSON interface.

@OleksiyMoroz
Copy link

@levlam Thank you! Seems need to work with JSON wrapper

@x2bool
Copy link

x2bool commented Mar 5, 2018

@OleksiyMoroz what is your use case?

I generated JSON API to C# bindings (.NET Standard 2.0) from this: https://github.com/tdlib/td/blob/master/td/generate/scheme/td_api.tl. I might consider opensourcing it if that would help anyone.

@isopen
Copy link
Contributor

isopen commented Mar 5, 2018

The interruption of the Preston cycle was caused by 😶
@levlam Thanks

@isopen
Copy link
Contributor

isopen commented Mar 5, 2018

@x2bool Show please how to do it. Your idea will help me better understand the essence.

@OleksiyMoroz
Copy link

@x2bool Do you have working examples usign JSON interface? Do you try to save media?

@x2bool
Copy link

x2bool commented Mar 5, 2018

Here you go: https://github.com/x2bool/tdsharp

@karb0f0s
Copy link

@x2bool How did you manage to do that? Is it possible to convert field names to snake case?

@x2bool
Copy link

x2bool commented Mar 13, 2018

Do you mean CamelCase, because fields are already in snake_case?

P.S. let's move this discussion to my repo

@karb0f0s
Copy link

Sorry, you are right, I mean CamelCase, it is more convenient in C#

@levlam
Copy link
Contributor

levlam commented Mar 19, 2018

Sorry for the delay. C# native bindings have been released as part of TDLib 1.2.0 release. See README for build instructions and usage example.

@x2bool
Copy link

x2bool commented Mar 19, 2018

Hi! Thanks for C# bindings. I opened an issue about .NET Core support since it is now an important platform for many developers. And also because of the fact that JSON serialization/deserialization creates significant overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants