OpenZWave / openzwave-dotnet-uwp

An Open-ZWave wrapper for use with .NET or UWP apps
Apache License 2.0
45 stars 27 forks source link

.NET Core support. #20

Open tommymh opened 6 years ago

tommymh commented 6 years ago

Is there any plan to add .NET Core support?

dotMorten commented 6 years ago

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?

tommymh commented 6 years ago

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.

ghost commented 5 years ago

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.

dotMorten commented 5 years ago

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).

ftballguy45 commented 3 years ago

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

tommymh commented 3 years ago

@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.

dotMorten commented 3 years ago

@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).

tommymh commented 3 years ago

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.

AndreMarschalek commented 3 years ago

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

dotMorten commented 3 years ago

@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.