Skip to content

Commit f159402

Browse files
authored
System.Net.NetworkInformation UnsupportedOSPlatform attributes (#57281)
* Added UnsupportedOSPlatform attributes to PNSE thowing methods * Replaced unix with the list of OSes
1 parent 61075fb commit f159402

30 files changed

+360
-0
lines changed

src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ protected IPGlobalProperties() { }
138138
public abstract System.Net.IPEndPoint[] GetActiveUdpListeners();
139139
public abstract System.Net.NetworkInformation.IcmpV4Statistics GetIcmpV4Statistics();
140140
public abstract System.Net.NetworkInformation.IcmpV6Statistics GetIcmpV6Statistics();
141+
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
142+
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
141143
public static System.Net.NetworkInformation.IPGlobalProperties GetIPGlobalProperties() { throw null; }
142144
public abstract System.Net.NetworkInformation.IPGlobalStatistics GetIPv4GlobalStatistics();
143145
public abstract System.Net.NetworkInformation.IPGlobalStatistics GetIPv6GlobalStatistics();
@@ -310,10 +312,14 @@ protected NetworkInterface() { }
310312
public virtual System.Net.NetworkInformation.OperationalStatus OperationalStatus { get { throw null; } }
311313
public virtual long Speed { get { throw null; } }
312314
public virtual bool SupportsMulticast { get { throw null; } }
315+
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
316+
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
313317
public static System.Net.NetworkInformation.NetworkInterface[] GetAllNetworkInterfaces() { throw null; }
314318
public virtual System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties() { throw null; }
315319
public virtual System.Net.NetworkInformation.IPInterfaceStatistics GetIPStatistics() { throw null; }
316320
public virtual System.Net.NetworkInformation.IPv4InterfaceStatistics GetIPv4Statistics() { throw null; }
321+
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
322+
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
317323
public static bool GetIsNetworkAvailable() { throw null; }
318324
public virtual System.Net.NetworkInformation.PhysicalAddress GetPhysicalAddress() { throw null; }
319325
public virtual bool Supports(System.Net.NetworkInformation.NetworkInterfaceComponent networkInterfaceComponent) { throw null; }

src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@
186186
<Compile Include="System\Net\NetworkInformation\NetworkInterfacePal.UnknownUnix.cs" />
187187
<Compile Include="System\Net\NetworkInformation\NetworkAddressChange.UnknownUnix.cs" />
188188
</ItemGroup>
189+
<ItemGroup>
190+
<SupportedPlatform Include="illumos"/>
191+
<SupportedPlatform Include="Solaris "/>
192+
</ItemGroup>
189193
<ItemGroup>
190194
<Reference Include="Microsoft.Win32.Primitives" />
191195
<Reference Include="System.Collections" />

src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPGlobalProperties.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Runtime.Versioning;
5+
46
namespace System.Net.NetworkInformation
57
{
68
internal sealed class BsdIPGlobalProperties : UnixIPGlobalProperties
@@ -135,6 +137,10 @@ public override IPGlobalStatistics GetIPv4GlobalStatistics()
135137
return new BsdIPv4GlobalStatistics();
136138
}
137139

140+
[UnsupportedOSPlatform("osx")]
141+
[UnsupportedOSPlatform("ios")]
142+
[UnsupportedOSPlatform("tvos")]
143+
[UnsupportedOSPlatform("freebsd")]
138144
public override IPGlobalStatistics GetIPv6GlobalStatistics()
139145
{
140146
// Although there is a 'net.inet6.ip6.stats' sysctl variable, there

src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4GlobalStatistics.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Runtime.CompilerServices;
66
using System.Runtime.InteropServices;
7+
using System.Runtime.Versioning;
78

89
namespace System.Net.NetworkInformation
910
{
@@ -95,18 +96,38 @@ public unsafe BsdIPv4GlobalStatistics()
9596

9697
public override long OutputPacketRequests { get { return _outboundPackets; } }
9798

99+
[UnsupportedOSPlatform("osx")]
100+
[UnsupportedOSPlatform("ios")]
101+
[UnsupportedOSPlatform("tvos")]
102+
[UnsupportedOSPlatform("freebsd")]
98103
public override long OutputPacketRoutingDiscards { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
99104

105+
[UnsupportedOSPlatform("osx")]
106+
[UnsupportedOSPlatform("ios")]
107+
[UnsupportedOSPlatform("tvos")]
108+
[UnsupportedOSPlatform("freebsd")]
100109
public override long OutputPacketsDiscarded { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
101110

102111
public override long OutputPacketsWithNoRoute { get { return _outputPacketsNoRoute; } }
103112

113+
[UnsupportedOSPlatform("osx")]
114+
[UnsupportedOSPlatform("ios")]
115+
[UnsupportedOSPlatform("tvos")]
116+
[UnsupportedOSPlatform("freebsd")]
104117
public override long PacketFragmentFailures { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
105118

119+
[UnsupportedOSPlatform("osx")]
120+
[UnsupportedOSPlatform("ios")]
121+
[UnsupportedOSPlatform("tvos")]
122+
[UnsupportedOSPlatform("freebsd")]
106123
public override long PacketReassembliesRequired { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
107124

108125
public override long PacketReassemblyFailures { get { return _cantFrags; } }
109126

127+
[UnsupportedOSPlatform("osx")]
128+
[UnsupportedOSPlatform("ios")]
129+
[UnsupportedOSPlatform("tvos")]
130+
[UnsupportedOSPlatform("freebsd")]
110131
public override long PacketReassemblyTimeout { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
111132

112133
public override long PacketsFragmented { get { return _datagramsFragmented; } }

src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4InterfaceProperties.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Runtime.Versioning;
5+
46
namespace System.Net.NetworkInformation
57
{
68
internal sealed class BsdIPv4InterfaceProperties : UnixIPv4InterfaceProperties
@@ -13,17 +15,37 @@ public BsdIPv4InterfaceProperties(BsdNetworkInterface oni, int mtu)
1315
_mtu = mtu;
1416
}
1517

18+
[UnsupportedOSPlatform("osx")]
19+
[UnsupportedOSPlatform("ios")]
20+
[UnsupportedOSPlatform("tvos")]
21+
[UnsupportedOSPlatform("freebsd")]
1622
public override bool IsAutomaticPrivateAddressingActive { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
1723

24+
[UnsupportedOSPlatform("osx")]
25+
[UnsupportedOSPlatform("ios")]
26+
[UnsupportedOSPlatform("tvos")]
27+
[UnsupportedOSPlatform("freebsd")]
1828
public override bool IsAutomaticPrivateAddressingEnabled { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
1929

30+
[UnsupportedOSPlatform("osx")]
31+
[UnsupportedOSPlatform("ios")]
32+
[UnsupportedOSPlatform("tvos")]
33+
[UnsupportedOSPlatform("freebsd")]
2034
public override bool IsDhcpEnabled { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
2135

2236
// Doesn't seem to be exposed on a per-interface basis.
37+
[UnsupportedOSPlatform("osx")]
38+
[UnsupportedOSPlatform("ios")]
39+
[UnsupportedOSPlatform("tvos")]
40+
[UnsupportedOSPlatform("freebsd")]
2341
public override bool IsForwardingEnabled { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
2442

2543
public override int Mtu { get { return _mtu; } }
2644

45+
[UnsupportedOSPlatform("osx")]
46+
[UnsupportedOSPlatform("ios")]
47+
[UnsupportedOSPlatform("tvos")]
48+
[UnsupportedOSPlatform("freebsd")]
2749
public override bool UsesWins { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
2850
}
2951
}

src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv4InterfaceStatistics.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Runtime.Versioning;
5+
46
namespace System.Net.NetworkInformation
57
{
68
internal sealed class BsdIPv4InterfaceStatistics : IPv4InterfaceStatistics
@@ -26,6 +28,10 @@ public BsdIPv4InterfaceStatistics(string name)
2628

2729
public override long NonUnicastPacketsSent => _statistics.NonUnicastPacketsSent;
2830

31+
[UnsupportedOSPlatform("osx")]
32+
[UnsupportedOSPlatform("ios")]
33+
[UnsupportedOSPlatform("tvos")]
34+
[UnsupportedOSPlatform("freebsd")]
2935
public override long OutgoingPacketsDiscarded => _statistics.OutgoingPacketsDiscarded;
3036

3137
public override long OutgoingPacketsWithErrors => _statistics.OutgoingPacketsWithErrors;

src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPv6InterfaceProperties.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Runtime.Versioning;
5+
46
namespace System.Net.NetworkInformation
57
{
68
internal sealed class BsdIPv6InterfaceProperties : UnixIPv6InterfaceProperties
@@ -15,6 +17,10 @@ public BsdIPv6InterfaceProperties(BsdNetworkInterface oni, int mtu)
1517

1618
public override int Mtu { get { return _mtu; } }
1719

20+
[UnsupportedOSPlatform("osx")]
21+
[UnsupportedOSPlatform("ios")]
22+
[UnsupportedOSPlatform("tvos")]
23+
[UnsupportedOSPlatform("freebsd")]
1824
public override long GetScopeId(ScopeLevel scopeLevel)
1925
{
2026
throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform);

src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV4Statistics.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Runtime.Versioning;
5+
46
namespace System.Net.NetworkInformation
57
{
68
internal sealed class BsdIcmpV4Statistics : IcmpV4Statistics
@@ -80,12 +82,28 @@ public BsdIcmpV4Statistics()
8082

8183
public override long EchoRequestsSent { get { return _echoRequestsSent; } }
8284

85+
[UnsupportedOSPlatform("osx")]
86+
[UnsupportedOSPlatform("ios")]
87+
[UnsupportedOSPlatform("tvos")]
88+
[UnsupportedOSPlatform("freebsd")]
8389
public override long ErrorsReceived { get { throw new PlatformNotSupportedException(); } }
8490

91+
[UnsupportedOSPlatform("osx")]
92+
[UnsupportedOSPlatform("ios")]
93+
[UnsupportedOSPlatform("tvos")]
94+
[UnsupportedOSPlatform("freebsd")]
8595
public override long ErrorsSent { get { throw new PlatformNotSupportedException(); } }
8696

97+
[UnsupportedOSPlatform("osx")]
98+
[UnsupportedOSPlatform("ios")]
99+
[UnsupportedOSPlatform("tvos")]
100+
[UnsupportedOSPlatform("freebsd")]
87101
public override long MessagesReceived { get { throw new PlatformNotSupportedException(); } }
88102

103+
[UnsupportedOSPlatform("osx")]
104+
[UnsupportedOSPlatform("ios")]
105+
[UnsupportedOSPlatform("tvos")]
106+
[UnsupportedOSPlatform("freebsd")]
89107
public override long MessagesSent { get { throw new PlatformNotSupportedException(); } }
90108

91109
public override long ParameterProblemsReceived { get { return _parameterProblemsReceived; } }

src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIcmpV6Statistics.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Runtime.Versioning;
5+
46
namespace System.Net.NetworkInformation
57
{
68
internal sealed class BsdIcmpV6Statistics : IcmpV6Statistics
@@ -84,12 +86,28 @@ public BsdIcmpV6Statistics()
8486

8587
public override long EchoRequestsSent { get { return _echoRequestsSent; } }
8688

89+
[UnsupportedOSPlatform("osx")]
90+
[UnsupportedOSPlatform("ios")]
91+
[UnsupportedOSPlatform("tvos")]
92+
[UnsupportedOSPlatform("freebsd")]
8793
public override long ErrorsReceived { get { throw new PlatformNotSupportedException(); } }
8894

95+
[UnsupportedOSPlatform("osx")]
96+
[UnsupportedOSPlatform("ios")]
97+
[UnsupportedOSPlatform("tvos")]
98+
[UnsupportedOSPlatform("freebsd")]
8999
public override long ErrorsSent { get { throw new PlatformNotSupportedException(); } }
90100

101+
[UnsupportedOSPlatform("osx")]
102+
[UnsupportedOSPlatform("ios")]
103+
[UnsupportedOSPlatform("tvos")]
104+
[UnsupportedOSPlatform("freebsd")]
91105
public override long MessagesReceived { get { throw new PlatformNotSupportedException(); } }
92106

107+
[UnsupportedOSPlatform("osx")]
108+
[UnsupportedOSPlatform("ios")]
109+
[UnsupportedOSPlatform("tvos")]
110+
[UnsupportedOSPlatform("freebsd")]
93111
public override long MessagesSent { get { throw new PlatformNotSupportedException(); } }
94112

95113
public override long ParameterProblemsReceived { get { return _parameterProblemsReceived; } }

src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Runtime.CompilerServices;
66
using System.Runtime.InteropServices;
7+
using System.Runtime.Versioning;
78

89
namespace System.Net.NetworkInformation
910
{
@@ -20,16 +21,36 @@ public BsdIpInterfaceProperties(BsdNetworkInterface oni, int mtu) : base(oni)
2021
_gatewayAddresses = GetGatewayAddresses(oni.Index);
2122
}
2223

24+
[UnsupportedOSPlatform("osx")]
25+
[UnsupportedOSPlatform("ios")]
26+
[UnsupportedOSPlatform("tvos")]
27+
[UnsupportedOSPlatform("freebsd")]
2328
public override IPAddressInformationCollection AnycastAddresses { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
2429

30+
[UnsupportedOSPlatform("osx")]
31+
[UnsupportedOSPlatform("ios")]
32+
[UnsupportedOSPlatform("tvos")]
33+
[UnsupportedOSPlatform("freebsd")]
2534
public override IPAddressCollection DhcpServerAddresses { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
2635

2736
public override GatewayIPAddressInformationCollection GatewayAddresses { get { return _gatewayAddresses; } }
2837

38+
[UnsupportedOSPlatform("osx")]
39+
[UnsupportedOSPlatform("ios")]
40+
[UnsupportedOSPlatform("tvos")]
41+
[UnsupportedOSPlatform("freebsd")]
2942
public override bool IsDnsEnabled { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
3043

44+
[UnsupportedOSPlatform("osx")]
45+
[UnsupportedOSPlatform("ios")]
46+
[UnsupportedOSPlatform("tvos")]
47+
[UnsupportedOSPlatform("freebsd")]
3148
public override bool IsDynamicDnsEnabled { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
3249

50+
[UnsupportedOSPlatform("osx")]
51+
[UnsupportedOSPlatform("ios")]
52+
[UnsupportedOSPlatform("tvos")]
53+
[UnsupportedOSPlatform("freebsd")]
3354
public override IPAddressCollection WinsServersAddresses { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
3455

3556
public override IPv4InterfaceProperties GetIPv4Properties()

0 commit comments

Comments
 (0)