-
Notifications
You must be signed in to change notification settings - Fork 16
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
.NET Standard support #72
Comments
Not being familiar with .NET myself: would .NET support require building a new library, or is this something that can be added to libSBOL in a fairly lightweight manner? |
(ps: I have removed the "SEP" marker, since that is generally used for changes to the specification, and this is a request for changes to the library) |
@jakebeal On .NET we can use P/Invoke (Platform Invoke) to wrap shared libraries' methods so that .NET can invoke methods in shared libraries directly without changing their original codes. It is like JNI in Java but won't require changes in original libraries' code. For example, an export function in a C++ shared library is: extern "C" int test(int a, const char* b); // assume that its ordinal is 0 We can write in C#: [DllImport("./xxx.so", EntryPoint = "#0", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] // the EntryPoint can be #ordinal or function name, so we can write either EntryPoint = "#0" or EntryPoint = "test"
static int Test(int a, [MarshalAs(UnmanagedType.LPStr)] string b); And we can use it by calling Test(int, string). |
Sounds like it could be implemented in much the same way as pySBOL currently wraps libSBOL. Would you be interested in building that library? I expect the community would be happy to endorse it once it exists! |
I could to do this but it depends on my free time. |
As with all of us. :-) |
I think you probably want to log this issue with our C++ library issue tracker, here:
https://github.com/SynBioDex/libSBOL <https://github.com/SynBioDex/libSBOL>
… On Mar 8, 2019, at 7:55 AM, Steve ***@***.***> wrote:
@jakebeal <https://github.com/jakebeal>
On .NET we use P/Invoke (Platform Invoke) to wrap C++ methods so that .NET can invoke methods in C++ shared libraries directly without changing C++ code.
For example, an export function in a C++ shared library is:
extern "C" int test(int a, const char* b); // assume that its ordinal is 0
We can write in C#:
[DllImport("./xxx.so", EntryPoint = "#0", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] // the EntryPoint can be #ordinal or function name, so we can write either EntryPoint = "#0" or EntryPoint = "test"
static int Test(int a, [MarshalAs(UnmanagedType.LPStr)] string b);
And we can use it by calling Test(int, string) in .NET Standard.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#72 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ADWD91iFvpp1y-2Onl8-AZWTkABbcyvDks5vUnnzgaJpZM4bla2w>.
|
Sounds great. |
closing this since it is now covered in SynBioDex/libSBOL#213 |
Can you add support for .NET Standard?
Then we can use libSBOL in .NET Core and .NET Framework apps.
Thanks.
The text was updated successfully, but these errors were encountered: