sharpbrick / powered-up

.NET implementation of the LEGO PoweredUp Protocol
MIT License
98 stars 19 forks source link

Add support for Windows App SDK projects #137

Open wldevries opened 3 years ago

wldevries commented 3 years ago

The library uses the WinRT Bluetooth API, so this should be possible. It confuses me that the SharpBrick.PoweredUp.WinRT package does not target UWP.

tthiery commented 3 years ago

Yeah ... that is the epic confusion the Windows division at Microsoft has unleashed on us.

So to my understanding:

Therefore the naming of WinRT in the Bluetooth layer.

Microsoft is currently not fully supporting C# 8.0 for UWP (I think Span and default interface methods when I remember right). This is planned (to my humble understanding) for end of 2021 when they enable .NET 5 or .NET 6 on UWP. There is Project Reunion which is dramatically reworking the space right now.

I know that this library has a very limited installation based (basically .NET Core 3.1 + with .NET Core based WinForms/WPF). I am open for a discussion around enabling it on UWP. However, I would prefer avoiding a major rework if later the year it gracefully resolves itself.

wldevries commented 3 years ago

Thanks for the reply. As far as I understand it UWP is the new name of what WinRT used to be, so just a marketing term. I'm not sure, but I get the feeling they intend to replace UWP entirely with the new WinUI framework.

As for UWP support, I really don't need this library to work with UWP, but if you did do a rework you could support .NET Framework as well. I guess hobby projects tend to use newer tools, so that's probably not worth it.

tthiery commented 3 years ago

I would love to support the .NET Framework for people playing with older tools. But the framework does not support the toys I want to play with (aka. C# 8.0 oder C# 9.0).

I think I let the time handle this. Are you bound to .NET Framework?

Berdsen commented 3 years ago

Hi @tthiery and @wldevries, I'm not tot deep into UWP developing but I guess it can use .netstandard 2.1 libraries? I played a little bit around with the Mobile / Xamarin solution and when using the correct Plugin.BLE version I could create a Xamarin UWP project.

As I said, I'm not too deep into UWP so I'm not knowing exactly where the differences between Xamarin UWP and a real UWP solutions are, but it might be worth a shot, to implement this into the mobile lib?

wldevries commented 3 years ago

The problem is that you cannot target a NET Standard 2.0 library that uses Windows SDK methods. The library will need to target uap10.0.0.17763 or something similar. Adding a dependency on Microsoft.Windows.SDK.Contracts in the library will cause compile time problems for the UWP project.

As far as I'm concerned this ticket can be closed. Anyway UWP will be superseded by WinUI 3 very soon.

tthiery commented 3 years ago

@Berdsen Interesting. To my understanding, netstandard2.1 is not supported on UWP and .NET Framework. That means Span and certain C# 8+ features are not supported. That eliminates the SharpBrick.PoweredUp core library to be unusable in its current state. The WinRT BT Adapter could be multi-targeted I guess, but I do not want to be restricted by UWP C# currently.

Like @wldevries: the wave of WinUI 3 will solve this soon. Build Conference is in 11 days, then we should also hear some updates from Microsoft on the topic.

tthiery commented 3 years ago

@wldevries I keep this open to track the progress.

tthiery commented 2 years ago

It looks like UWP is not getting updated to .NET 5 and .NET 6.

Way forward is Windows App SDK apps using WinUI 3.