Skip to content

Commit 7c30259

Browse files
authored
[NetworkExtension] Improve and simplify the manually bound constructors for NEHotspotConfiguration slightly. (#22665)
Improve and simplify the manually bound constructors for NEHotspotConfiguration by using the same pattern we use elsewhere for manually bound constructors.
1 parent 318ba23 commit 7c30259

File tree

5 files changed

+34
-37
lines changed

5 files changed

+34
-37
lines changed

src/NetworkExtension/NEHotspotConfiguration.cs

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,58 @@ namespace NetworkExtension {
1010

1111
public partial class NEHotspotConfiguration {
1212

13-
/// <param name="ssid">To be added.</param>
14-
/// <summary>To be added.</summary>
15-
/// <remarks>To be added.</remarks>
13+
/// <summary>Create a new <see cref="NEHotspotConfiguration" /> with the specified SSID.</summary>
14+
/// <param name="ssid">The SSID the new <see cref="NEHotspotConfiguration" /> applies to.</param>
1615
public NEHotspotConfiguration (string ssid)
16+
: base (NSObjectFlag.Empty)
1717
{
18-
InitializeHandle (initWithSsid (ssid));
18+
InitializeHandle (_InitWithSsid (ssid), "initWithSSID:");
1919
}
2020

21-
/// <param name="ssid">To be added.</param>
22-
/// <param name="passphrase">To be added.</param>
23-
/// <param name="isWep">To be added.</param>
24-
/// <summary>To be added.</summary>
25-
/// <remarks>To be added.</remarks>
21+
/// <summary>Create a new <see cref="NEHotspotConfiguration" /> with the specified SSID.</summary>
22+
/// <param name="ssid">The SSID the new <see cref="NEHotspotConfiguration" /> applies to.</param>
23+
/// <param name="passphrase">The passphrase for the network specified by <paramref name="ssid" />.</param>
24+
/// <param name="isWep">Whether the network is a WEP network (otherwise a WPA or WPA2 network).</param>
2625
public NEHotspotConfiguration (string ssid, string passphrase, bool isWep)
26+
: base (NSObjectFlag.Empty)
2727
{
28-
InitializeHandle (initWithSsid (ssid, passphrase, isWep));
28+
InitializeHandle (_InitWithSsidAndPassprase (ssid, passphrase, isWep), "initWithSSID:passphrase:isWEP:");
2929
}
3030

31-
#if NET
31+
/// <summary>Create a new <see cref="NEHotspotConfiguration" /> with the specified SSID.</summary>
32+
/// <param name="ssid">The SSID the new <see cref="NEHotspotConfiguration" /> applies to.</param>
33+
/// <param name="ssidIsPrefix">Whether <paramref name="ssid" /> specifies the prefix of an SSID, or a complete SSID.</param>
3234
[SupportedOSPlatform ("ios13.0")]
3335
[SupportedOSPlatform ("maccatalyst")]
3436
[UnsupportedOSPlatform ("macos")]
3537
[UnsupportedOSPlatform ("tvos")]
36-
#else
37-
[iOS (13, 0)]
38-
#endif
3938
public NEHotspotConfiguration (string ssid, bool ssidIsPrefix)
39+
: base (NSObjectFlag.Empty)
4040
{
41-
var h = ssidIsPrefix ? initWithSsidPrefix (ssid) : initWithSsid (ssid);
42-
InitializeHandle (h);
41+
if (ssidIsPrefix) {
42+
InitializeHandle (_InitWithSsidPrefix (ssid), "initWithSSIDPrefix:");
43+
} else {
44+
InitializeHandle (_InitWithSsid (ssid), "initWithSSID:");
45+
}
4346
}
4447

45-
#if NET
48+
/// <summary>Create a new <see cref="NEHotspotConfiguration" /> with the specified SSID.</summary>
49+
/// <param name="ssid">The SSID the new <see cref="NEHotspotConfiguration" /> applies to.</param>
50+
/// <param name="passphrase">The passphrase for the network specified by <paramref name="ssid" />.</param>
51+
/// <param name="isWep">Whether the network is a WEP network (otherwise a WPA or WPA2 network).</param>
52+
/// <param name="ssidIsPrefix">Whether <paramref name="ssid" /> specifies the prefix of an SSID, or a complete SSID.</param>
4653
[SupportedOSPlatform ("ios13.0")]
4754
[SupportedOSPlatform ("maccatalyst")]
4855
[UnsupportedOSPlatform ("macos")]
4956
[UnsupportedOSPlatform ("tvos")]
50-
#else
51-
[iOS (13, 0)]
52-
#endif
5357
public NEHotspotConfiguration (string ssid, string passphrase, bool isWep, bool ssidIsPrefix)
58+
: base (NSObjectFlag.Empty)
5459
{
55-
var h = ssidIsPrefix ? initWithSsidPrefix (ssid, passphrase, isWep) : initWithSsid (ssid, passphrase, isWep);
56-
InitializeHandle (h);
60+
if (ssidIsPrefix) {
61+
InitializeHandle (_InitWithSsidPrefixAndPassphrase (ssid, passphrase, isWep), "initWithSSIDPrefix:passphrase:isWEP:");
62+
} else {
63+
InitializeHandle (_InitWithSsidAndPassprase (ssid, passphrase, isWep), "initWithSSID:passphrase:isWEP:");
64+
}
5765
}
5866
}
5967
}

src/networkextension.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4410,11 +4410,11 @@ interface NEHotspotConfiguration : NSCopying, NSSecureCoding {
44104410

44114411
[Internal]
44124412
[Export ("initWithSSID:")]
4413-
IntPtr initWithSsid (string ssid);
4413+
IntPtr _InitWithSsid (string ssid);
44144414

44154415
[Internal]
44164416
[Export ("initWithSSID:passphrase:isWEP:")]
4417-
IntPtr initWithSsid (string ssid, string passphrase, bool isWep);
4417+
IntPtr _InitWithSsidAndPassprase (string ssid, string passphrase, bool isWep);
44184418

44194419
/// <param name="ssid">To be added.</param>
44204420
/// <param name="eapSettings">To be added.</param>
@@ -4434,13 +4434,13 @@ interface NEHotspotConfiguration : NSCopying, NSSecureCoding {
44344434
[iOS (13, 0)]
44354435
[MacCatalyst (13, 1)]
44364436
[Export ("initWithSSIDPrefix:")]
4437-
IntPtr initWithSsidPrefix (string ssidPrefix);
4437+
IntPtr _InitWithSsidPrefix (string ssidPrefix);
44384438

44394439
[Internal]
44404440
[iOS (13, 0)]
44414441
[MacCatalyst (13, 1)]
44424442
[Export ("initWithSSIDPrefix:passphrase:isWEP:")]
4443-
IntPtr initWithSsidPrefix (string ssidPrefix, string passphrase, bool isWep);
4443+
IntPtr _InitWithSsidPrefixAndPassphrase (string ssidPrefix, string passphrase, bool isWep);
44444444

44454445
[iOS (13, 0)]
44464446
[MacCatalyst (13, 1)]

tests/cecil-tests/ConstructorTest.KnownFailures.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ public partial class ConstructorTest {
4646
"ModelIO.MDLMesh::.ctor(System.Numerics.Vector3,CoreGraphics.NVector3i,System.Boolean,ModelIO.MDLGeometryType,ModelIO.IMDLMeshBufferAllocator)",
4747
"ModelIO.MDLMesh::.ctor(System.Numerics.Vector3,System.Boolean,ModelIO.MDLGeometryType,ModelIO.IMDLMeshBufferAllocator)",
4848
"ModelIO.MDLNoiseTexture::.ctor(System.Single,System.String,CoreGraphics.NVector2i,ModelIO.MDLTextureChannelEncoding,ModelIO.MDLNoiseTextureType)",
49-
"NetworkExtension.NEHotspotConfiguration::.ctor(System.String,System.Boolean)",
50-
"NetworkExtension.NEHotspotConfiguration::.ctor(System.String,System.String,System.Boolean,System.Boolean)",
51-
"NetworkExtension.NEHotspotConfiguration::.ctor(System.String,System.String,System.Boolean)",
52-
"NetworkExtension.NEHotspotConfiguration::.ctor(System.String)",
5349
"SpriteKit.SKUniform::.ctor(System.String,System.Numerics.Vector2)",
5450
"SpriteKit.SKUniform::.ctor(System.String,System.Numerics.Vector3)",
5551
"SpriteKit.SKUniform::.ctor(System.String,System.Numerics.Vector4)",

tests/cecil-tests/Documentation.KnownFailures.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14299,8 +14299,6 @@ M:NetworkExtension.NEFilterPacketProvider.DelayCurrentPacket(NetworkExtension.NE
1429914299
M:NetworkExtension.NEFilterProvider.HandleReport(NetworkExtension.NEFilterReport)
1430014300
M:NetworkExtension.NEFilterRule.#ctor(NetworkExtension.NENetworkRule,NetworkExtension.NEFilterAction)
1430114301
M:NetworkExtension.NEFilterSettings.#ctor(NetworkExtension.NEFilterRule[],NetworkExtension.NEFilterAction)
14302-
M:NetworkExtension.NEHotspotConfiguration.#ctor(System.String,System.Boolean)
14303-
M:NetworkExtension.NEHotspotConfiguration.#ctor(System.String,System.String,System.Boolean,System.Boolean)
1430414302
M:NetworkExtension.NEHotspotConfigurationManager.JoinAccessoryHotspot(AccessorySetupKit.ASAccessory,System.String,NetworkExtension.NEHotspotConfigurationManagerJoinHotspotCallback)
1430514303
M:NetworkExtension.NEHotspotConfigurationManager.JoinAccessoryHotspotAsync(AccessorySetupKit.ASAccessory,System.String)
1430614304
M:NetworkExtension.NEHotspotConfigurationManager.JoinAccessoryHotspotWithoutSecurit(AccessorySetupKit.ASAccessory,NetworkExtension.NEHotspotConfigurationManagerJoinHotspotCallback)

tests/introspection/ApiSelectorTest.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,11 +1354,6 @@ protected virtual bool SkipInit (string selector, MethodBase m)
13541354
case "initWithUUID:identifier:":
13551355
case "initWithUUID:major:identifier:":
13561356
case "initWithUUID:major:minor:identifier:":
1357-
// NEHotspotConfiguration
1358-
case "initWithSSID:":
1359-
case "initWithSSID:passphrase:isWEP:":
1360-
case "initWithSSIDPrefix:":
1361-
case "initWithSSIDPrefix:passphrase:isWEP:":
13621357
var mi = m as MethodInfo;
13631358
return mi is not null && !mi.IsPublic && (mi.ReturnType.Name == "IntPtr" || mi.ReturnType.Name == "NativeHandle");
13641359
// NSAppleEventDescriptor

0 commit comments

Comments
 (0)