Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ protected IPGlobalProperties() { }
public abstract System.Net.IPEndPoint[] GetActiveUdpListeners();
public abstract System.Net.NetworkInformation.IcmpV4Statistics GetIcmpV4Statistics();
public abstract System.Net.NetworkInformation.IcmpV6Statistics GetIcmpV6Statistics();
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need to care about unsupported OSes.
There is really now way how somebody can target them right now AFAIK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have them as targets for this project:
https://github.com/dotnet/runtime/blob/8e92a6fe4d89934eba274e2a247c800a725d6de9/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj#L4
I assume that's the reason why it's firing the warnings.

@buyaa-n can probably share more detail about the inner working of the analyzer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that's the reason why it's firing the warnings.

Right when there is a target platform in the TFM that build going to be for that platform for the analyzer. Sounds like the case the API is supported on certain platforms and throws on all others, if you cannot use SupportedOSPlatform attributes with the realistic platforms then we can skip the warnings for these unrealistic platforms.

The PNSE analyzer will not be added to the repo its just one time run to detect missing annotations

public static System.Net.NetworkInformation.IPGlobalProperties GetIPGlobalProperties() { throw null; }
public abstract System.Net.NetworkInformation.IPGlobalStatistics GetIPv4GlobalStatistics();
public abstract System.Net.NetworkInformation.IPGlobalStatistics GetIPv6GlobalStatistics();
Expand Down Expand Up @@ -310,10 +312,14 @@ protected NetworkInterface() { }
public virtual System.Net.NetworkInformation.OperationalStatus OperationalStatus { get { throw null; } }
public virtual long Speed { get { throw null; } }
public virtual bool SupportsMulticast { get { throw null; } }
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
public static System.Net.NetworkInformation.NetworkInterface[] GetAllNetworkInterfaces() { throw null; }
public virtual System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties() { throw null; }
public virtual System.Net.NetworkInformation.IPInterfaceStatistics GetIPStatistics() { throw null; }
public virtual System.Net.NetworkInformation.IPv4InterfaceStatistics GetIPv4Statistics() { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
public static bool GetIsNetworkAvailable() { throw null; }
public virtual System.Net.NetworkInformation.PhysicalAddress GetPhysicalAddress() { throw null; }
public virtual bool Supports(System.Net.NetworkInformation.NetworkInterfaceComponent networkInterfaceComponent) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@
<Compile Include="System\Net\NetworkInformation\NetworkInterfacePal.UnknownUnix.cs" />
<Compile Include="System\Net\NetworkInformation\NetworkAddressChange.UnknownUnix.cs" />
</ItemGroup>
<ItemGroup>
<SupportedPlatform Include="illumos"/>
<SupportedPlatform Include="Solaris "/>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Win32.Primitives" />
<Reference Include="System.Collections" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Net.NetworkInformation
{
internal sealed class BsdIPGlobalProperties : UnixIPGlobalProperties
Expand Down Expand Up @@ -135,6 +137,10 @@ public override IPGlobalStatistics GetIPv4GlobalStatistics()
return new BsdIPv4GlobalStatistics();
}

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override IPGlobalStatistics GetIPv6GlobalStatistics()
{
// Although there is a 'net.inet6.ip6.stats' sysctl variable, there
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

namespace System.Net.NetworkInformation
{
Expand Down Expand Up @@ -95,18 +96,38 @@ public unsafe BsdIPv4GlobalStatistics()

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

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long OutputPacketRoutingDiscards { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long OutputPacketsDiscarded { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

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

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long PacketFragmentFailures { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long PacketReassembliesRequired { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

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

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long PacketReassemblyTimeout { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

public override long PacketsFragmented { get { return _datagramsFragmented; } }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Net.NetworkInformation
{
internal sealed class BsdIPv4InterfaceProperties : UnixIPv4InterfaceProperties
Expand All @@ -13,17 +15,37 @@ public BsdIPv4InterfaceProperties(BsdNetworkInterface oni, int mtu)
_mtu = mtu;
}

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override bool IsAutomaticPrivateAddressingActive { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override bool IsAutomaticPrivateAddressingEnabled { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override bool IsDhcpEnabled { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

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

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

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override bool UsesWins { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Net.NetworkInformation
{
internal sealed class BsdIPv4InterfaceStatistics : IPv4InterfaceStatistics
Expand All @@ -26,6 +28,10 @@ public BsdIPv4InterfaceStatistics(string name)

public override long NonUnicastPacketsSent => _statistics.NonUnicastPacketsSent;

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long OutgoingPacketsDiscarded => _statistics.OutgoingPacketsDiscarded;

public override long OutgoingPacketsWithErrors => _statistics.OutgoingPacketsWithErrors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Net.NetworkInformation
{
internal sealed class BsdIPv6InterfaceProperties : UnixIPv6InterfaceProperties
Expand All @@ -15,6 +17,10 @@ public BsdIPv6InterfaceProperties(BsdNetworkInterface oni, int mtu)

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

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long GetScopeId(ScopeLevel scopeLevel)
{
throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Net.NetworkInformation
{
internal sealed class BsdIcmpV4Statistics : IcmpV4Statistics
Expand Down Expand Up @@ -80,12 +82,28 @@ public BsdIcmpV4Statistics()

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

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long ErrorsReceived { get { throw new PlatformNotSupportedException(); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long ErrorsSent { get { throw new PlatformNotSupportedException(); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long MessagesReceived { get { throw new PlatformNotSupportedException(); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long MessagesSent { get { throw new PlatformNotSupportedException(); } }

public override long ParameterProblemsReceived { get { return _parameterProblemsReceived; } }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Net.NetworkInformation
{
internal sealed class BsdIcmpV6Statistics : IcmpV6Statistics
Expand Down Expand Up @@ -84,12 +86,28 @@ public BsdIcmpV6Statistics()

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

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long ErrorsReceived { get { throw new PlatformNotSupportedException(); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long ErrorsSent { get { throw new PlatformNotSupportedException(); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long MessagesReceived { get { throw new PlatformNotSupportedException(); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long MessagesSent { get { throw new PlatformNotSupportedException(); } }

public override long ParameterProblemsReceived { get { return _parameterProblemsReceived; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

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

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override IPAddressInformationCollection AnycastAddresses { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override IPAddressCollection DhcpServerAddresses { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

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

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override bool IsDnsEnabled { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override bool IsDynamicDnsEnabled { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override IPAddressCollection WinsServersAddresses { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

public override IPv4InterfaceProperties GetIPv4Properties()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Net.NetworkInformation
{
internal sealed class BsdIpInterfaceStatistics : IPInterfaceStatistics
Expand Down Expand Up @@ -52,6 +54,10 @@ public BsdIpInterfaceStatistics(string name)

public override long NonUnicastPacketsSent { get { return _outNonUnicastPackets; } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long OutgoingPacketsDiscarded { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

public override long OutgoingPacketsWithErrors { get { return _outErrors; } }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Net.NetworkInformation
{
internal sealed class BsdTcpStatistics : TcpStatistics
Expand Down Expand Up @@ -46,14 +48,34 @@ public BsdTcpStatistics()

public override long FailedConnectionAttempts { get { return _failedConnectionAttempts; } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long MaximumConnections { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long MaximumTransmissionTimeout { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long MinimumTransmissionTimeout { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long ResetConnections { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

[UnsupportedOSPlatform("osx")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[UnsupportedOSPlatform("freebsd")]
public override long ResetsSent { get { throw new PlatformNotSupportedException(SR.net_InformationUnavailableOnPlatform); } }

public override long SegmentsReceived { get { return _segmentsReceived; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace System.Net.NetworkInformation
/// </summary>
public abstract class IPGlobalProperties
{
[UnsupportedOSPlatform("illumos")]
[UnsupportedOSPlatform("solaris")]
public static IPGlobalProperties GetIPGlobalProperties()
{
return IPGlobalPropertiesPal.GetIPGlobalProperties();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.Versioning;

namespace System.Net.NetworkInformation
{
internal static class IPGlobalPropertiesPal
{
[UnsupportedOSPlatform("illumos")]
[UnsupportedOSPlatform("solaris")]
public static IPGlobalProperties GetIPGlobalProperties()
{
throw new PlatformNotSupportedException();
Expand Down
Loading