CppSharp icon indicating copy to clipboard operation
CppSharp copied to clipboard

.NET Core generation support

Open benpye opened this issue 10 years ago • 12 comments

Whilst in an ideal world, it would be great to both run CppSharp on .NET and generate code for .NET Core I think currently it would suffice to just be able to generate code that is compatible with .NET Core. It would be great to be able to support all the new platforms that are to be added (OS X, Linux, FreeBSD) in the Microsoft framework, meaning that we wouldn't always need Mono there when wanting to use a CppSharp bound library.

benpye avatar Feb 29 '16 10:02 benpye

+1. What specific issues have you run into?

lilith avatar Mar 07 '16 16:03 lilith

The primary issue I have noticed is that SuppressUnmanagedSecurity is emitted.

On Mon, 7 Mar 2016, 16:41 Nathanael Jones, [email protected] wrote:

+1. What specific issues have you run into?

— Reply to this email directly or view it on GitHub https://github.com/mono/CppSharp/issues/629#issuecomment-193337705.

benpye avatar Mar 07 '16 16:03 benpye

SuppressUnmanagedSecurity is unfortunately vital to us because it skips certain checks when calling into native code thus significantly increasing performance. In order to solve this, we need more details. For example, is the problem that SuppressUnmanagedSecurity causes some problem with .NET Core or rather that it doesn't exist at all? Is there an alternative to it? In case there is, is there a #define we can place in the generated code to detect .NET Core?

ddobrev avatar Mar 07 '16 17:03 ddobrev

All P/Invoke's on CoreCLR effectively have this https://github.com/dotnet/coreclr/issues/1605

On Mon, 7 Mar 2016 at 17:13 Dimitar Dobrev [email protected] wrote:

SuppressUnmanagedSecurity is unfortunately vital to us because it skips certain checks when calling into native code thus significantly increasing performance. In order to solve this, we need more details. For example, is the problem that SuppressUnmanagedSecurity causes some problem with .NET Core or rather that it doesn't exist at all? Is there an alternative to it? In case there is, is there a #define we can place in the generated code to detect .NET Core?

— Reply to this email directly or view it on GitHub https://github.com/mono/CppSharp/issues/629#issuecomment-193351893.

benpye avatar Mar 07 '16 17:03 benpye

If that is the only issue on .NET Core then we can easily fix it, though ideally we should also integrate CoreCLR on the CI system to test against it on every commit.

tritao avatar Mar 07 '16 17:03 tritao

can we have a simple tutorial or example using a known c++ library to port it to .NET Core? If such a tutorial already available, please share the links

JimSEOW avatar May 26 '16 10:05 JimSEOW

@JimSEOW: You can use https://github.com/ddobrev/QtSharp as an example, or all the other open source projects linked on the README file. And you can also take a look at our test suite.

tritao avatar May 26 '16 11:05 tritao

Thanks @tritao, after extensive search through internet, I found (especially Japanese sites) offering step by step tutorials using the foo example. Thanks. cppSharp offers a much simpler experience than SWIG.

JimSEOW avatar May 29 '16 06:05 JimSEOW

CppSharp can now be compiled under .NET Core.

However the P/Invoke support in .NET Core is buggy on Linux, so we'll have to wait until support is fixed upstream.

https://github.com/dotnet/coreclr/issues/22087

tritao avatar Jan 19 '19 00:01 tritao

@tritao the fix for dotnet/coreclr#22087 should be in Preview 4.

jkoritzinsky avatar Apr 29 '19 20:04 jkoritzinsky

Awesome thanks for the fix! 👍

tritao avatar Apr 29 '19 20:04 tritao

To use the nuget package under netcore 2.2, it is needed to recompile this project and generate the output as nuget package?

cyberdecker avatar Sep 02 '19 14:09 cyberdecker