openzwave-dotnet-uwp icon indicating copy to clipboard operation
openzwave-dotnet-uwp copied to clipboard

.NET Core support.

Open tommymh opened this issue 7 years ago • 10 comments

Is there any plan to add .NET Core support?

tommymh avatar Jul 02 '18 21:07 tommymh

Short answer: No.

One thing to consider is this isn't a .NET Library. This is a native C++ Library that can be consumed by the .NET Framework or UWP, but it's all written in C++. It compiles as C++/CLI to expose it to the .NET Framework, and C++/CX to expose it to UWP.

To support .NET Core, it would have to be completely rewritten to expose a C-API that is then imported by .NET wrappers, which would be a significant amount of work, hard to maintain, and in the end it really wouldn't give you any new platforms, as there's still a native Windows library to call into. Sure we could technically compile a dynamic C-API library for Linux, but .NET Core doesn't really support mixing native code with .NET code cleanly, as the code paths would be different depending on the host-OS (you'd have to use a .NET Standard Nuget package with bait'n'switch and it quickly gets rather ugly). And that's if the resources where there to do a complete ground-up rewrite of this API. Also see #15 and #10

I'm curious why you require a .NET Core version of this API? Any reason you can't use .NET Framework?

dotMorten avatar Jul 03 '18 04:07 dotMorten

The main reason would be simple cross platform development. I also just really like the .NET Core tooling. Thanks for the detailed and prompt response.

tommymh avatar Jul 03 '18 11:07 tommymh

You could use https://github.com/OpenZWave/node-openzwave-shared together with https://github.com/aspnet/JavaScriptServices/tree/master/src/Microsoft.AspNetCore.NodeServices and create a wrapper around it that way.

ghost avatar Dec 25 '18 02:12 ghost

Reopening, as the WPF Team is building a C++ CLI compiler, so this might in fact become possible (not to mention .NET Framework is now essentially dead by November next year with .NET 5 shipping).

dotMorten avatar May 15 '19 20:05 dotMorten

Would be nice to have .Net core so we can run this on a Raspberry Pi

ftballguy45 avatar Oct 10 '20 11:10 ftballguy45

@dotMorten is there anything I could do to help move this forward? I don't have a ton of experience with C++/C# interop but I'd be happy to learn.

tommymh avatar Oct 10 '20 16:10 tommymh

@tommymh thanks for the offer, but as explained above this would be a complete 100% rewrite and be a significant effort as you'd have to write both the native classes to export methods, and managed code to import them and properly manage life cycle etc. As such it would likely be better to do in an entirely new repo. It would be a great thing to do and open up some great new features, but personally I just don't have the time to do it at this point but would be happy to support anyone undertaking this with some guidance and pointers as I do have a good amount of experience with it (it's basically what I do daily on the product I do as part of my day job).

dotMorten avatar Oct 11 '20 03:10 dotMorten

A complete rewrite is something that I also don't have the time for at the moment, but certainly something I'd like to attempt in the future. I will reach out for guidance when time allows.

tommymh avatar Oct 13 '20 15:10 tommymh

if you take a look at https://github.com/roblans/ZWave4Net it seems they already have .net core support please dont get me wrong currently i am searching also for a .net core solution working at the end on a linux based device and new devices should be easy to add in the future, dll loading for example or everything openzwave related will be in their own dll, home automation system based on asp.net core webapplication build everything from scratch means reverse engineer openzwave protocol, thats too much time consuming i think

AndreMarschalek avatar Oct 13 '20 19:10 AndreMarschalek

@cyberh0me Thanks for the link. That's definitely interesting, but from what I can tell, one thing to note is that that library isn't based around OpenZWave, but is a pure managed implementation.

dotMorten avatar Oct 13 '20 22:10 dotMorten