monke
`OperatingSystem.IsAndroid()` Alternative for .NET Standard 2.0
I am moving a library from .NET 8 to .NET Standard 2.0 since I would like to use it in a legacy .NET Framework project as well.
The only issue that I haven't been able to figure out a good way to resolve is
OperatingSystem.IsAndroid()
. This library includes an API client in it for our backend, so it gets used in both Windows desktop and an Android/iOS MAUI app and I use that to add a header so I know which platform the request came from. Right now I've replaced that with RuntimeInformation.OSDescription.ToLower().Contains("android")
, but this feels extremely fragile to me so I'm a bit worried with keeping it that way long term. Are there any good (non 3rd party nuget package) alternatives or ways to use OperatingSystem.IsAndroid()
?
I had to add the System.Text.Json library to get those classes back and am just not sure if there is a similar one for this OperatingSystem class. The big issue I'm running into trying to find info on this is everything is recommending using RuntimeInformation.IsOSPlatform(OSPlatform.*)
, however this does not contain a platform for android.105 replies