Bug 11890 - Please implement Android.Net.Wifi.WifiConfiguration.AllowedKeyManagement as an enum
Summary: Please implement Android.Net.Wifi.WifiConfiguration.AllowedKeyManagement as a...
Status: ASSIGNED
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.8.x
Hardware: PC Mac OS
: Lowest enhancement
Target Milestone: master
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2013-04-22 13:25 UTC by Bryan Moulton
Modified: 2016-09-21 13:27 UTC (History)
3 users (show)

Tags: XATriaged
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 11890 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
ASSIGNED

Description Bryan Moulton 2013-04-22 13:25:24 UTC
The property Android.Net.Wifi.WifiConfiguration.AllowedKeyManagement is currently a BitSet which is confusing for users and requires extra work than necessary. Can we break out the WifiConfiguration.KeyMgmt constants into an enum and handle this in the framework?
Comment 1 Bryan Moulton 2013-04-22 13:27:25 UTC
My mistake. Looks like the enum exists but not the implementation.
Comment 2 Atsushi Eno 2013-06-21 06:45:06 UTC
I did some quick search on how BitSet is used in Android API. From the result, I have to say it is very niche to handle those use of BitSet generally in our binding generator (only those WifiConfiguration fields were the use).

csharp> using System.Xml;
csharp> var doc = new XmlDocument (); doc.Load ("src/Mono.Android/api-17.xml.in"csharp> var nl = doc.SelectNodes ("/api/package/*/method/parameter[@type='java.util.BitSet']");
csharp> nl.Count
5
csharp> foreach (XmlElement el in nl) {                                               > var t = el.ParentNode.ParentNode as XmlElement;
      > var m = el.ParentNode as XmlElement;
      > Console.WriteLine ("{0}.{1} {2}", t.GetAttribute ("name"), m.GetAttribute ("name"), el.GetAttribute ("name"));
      > }
BitSet.and bs
BitSet.andNot bs
BitSet.intersects bs
BitSet.or bs
BitSet.xor bs
csharp> var nl = doc.SelectNodes ("/api/package/*/field[@type='java.util.BitSet'csharp> nl.Count                                                                5                                      
csharp> foreach (XmlElement el in nl) {                                               > var t = el.ParentNode.ParentNode as XmlElement;                               > var m = el.ParentNode as XmlElement;                                          > Console.WriteLine ("{0}.{1} {2}", t.GetAttribute ("name"), m.GetAttribute ("name"), el.GetAttribute ("name")); 
      > }
android.net.wifi.WifiConfiguration allowedAuthAlgorithms
android.net.wifi.WifiConfiguration allowedGroupCiphers
android.net.wifi.WifiConfiguration allowedKeyManagement
android.net.wifi.WifiConfiguration allowedPairwiseCiphers
android.net.wifi.WifiConfiguration allowedProtocols
csharp> var nl = doc.SelectNodes ("/api/package/*/method[@return='java.util.BitScsharp> nl.Count                                                                5                                      
csharp> foreach (XmlElement el in nl) {                                               > var t = el.ParentNode.ParentNode as XmlElement;                               > var m = el.ParentNode as XmlElement;                                          > Console.WriteLine ("{0}.{1} {2}", t.GetAttribute ("name"), m.GetAttribute ("name"), el.GetAttribute ("name")); 
      > }
java.util.BitSet get
java.util.BitSet valueOf
java.util.BitSet valueOf
java.util.BitSet valueOf
java.util.BitSet valueOf
csharp> quit

I'm not sure which form is the best API under the limitations (e.g. we cannot change the API signature).

1) add extension method to Android.Net.Wifi.KeyManagementType to convert this to BitSet. Easy, but when assigning a value to those BitSets, it's not very helpful because left operand of assignment is BitSet and won't give enum autocompletion.
2) add implicit operator to BitSet to convert to KeyManagementType. It's too hacky and won't work for enums outside Mono.Android.dll. Users cannot get this conversion feature, so others would get frustrated to see this. Also still missing autocompletion.
3) create another set of properties that simply converts and assigns those values into Bitsets. Easy, users get auto completion, but the resulting API is a bit ugly.
4) we implement some special casing in generator for those use of BitSets (method return/method parameter/field) to convert to and from some enum type when specified explicitly (e.g. <type ... convert-bitset="Android.Net.Wifi.KeyManagementType" />). I'm against this as it brings extra complication for very niche stuff.

I think 3) is fairly reasonable (ugly API in very few area), but would wait for any possible opinion before making change.