FreakyAli / Plugin.Maui.Biometric

A biometric plugin for .NET MAUI
MIT License
106 stars 11 forks source link

feat: added a way to confirm if a platform is supported by the plugin #8

Closed Dabbel closed 4 months ago

Dabbel commented 5 months ago

For net8 without platform target GetEnrolledBiometricTypesAsync should return BiometricType.None. This makes it possible to check on all platforms if biometric is support without an exception.

FreakyAli commented 5 months ago

The current implementation is correct, it is supposed to throw an exception so it can be unit-tested easily!

Dabbel commented 5 months ago

But on platforms that doesn't support biometric there isn't an easy way to check if biometric can be used. And to check if the exception is thrown is a very bad and ugly way to do it.

What is if there would be a bool property on IBiometric that indicates if that platform is able to support biometric? In net8 implementation that property would return false and for iOS and Android true.

FreakyAli commented 5 months ago

You cannot install this package for MacOS and Windows so if the platform is not supported you cannot even build it, And what would be the point of this property I am still unable to get it...

And to check if the exception is thrown is a very bad and ugly way to do it.

As far as I know most people test it that way... Probably even the .NET Maui team themselves...

Dabbel commented 5 months ago

For unit tests it is okay.

It is possible to install the package in every project that uses net8, only for iOS and Android the platform implementation will be used.

The platform moniker has fallbacks, if you target against net8-windows it will search for net8-windows in the nuget package. If it can't finde that it will fallback to net8.

With the property the developer that uses the package doesn't need to check for the exception if the platform is supported, he can use the property for that.

FreakyAli commented 5 months ago

@Dabbel Guess that makes sense, You can make these changes to your PR?

Dabbel commented 5 months ago

@FreakyAli will change it. Or do you find it better that net8 target without platform will be removed? This would result that platforms other than iOS and Android can not be build.

FreakyAli commented 5 months ago

@FreakyAli will change it. Or would it be better if the net8 target without a platform were removed? This would mean that platforms other than iOS and Android can not be built.

We need .net8 for unit testing, just add a property that returns false if its an unsupported platform.

Dabbel commented 5 months ago

Needed to implement a method, in the current c# version there is no partial property

FreakyAli commented 5 months ago

@Dabbel Don't you think you also need the property in the interface?

Dabbel commented 5 months ago

Sorry, totaly forgot the interface

FreakyAli commented 5 months ago

Happens to us all brother!