diff --git a/src/libraries/System.Net.NetworkInformation/Directory.Build.props b/src/libraries/System.Net.NetworkInformation/Directory.Build.props
index ce244cbea56199..d68d22c1b917f8 100644
--- a/src/libraries/System.Net.NetworkInformation/Directory.Build.props
+++ b/src/libraries/System.Net.NetworkInformation/Directory.Build.props
@@ -3,6 +3,5 @@
Microsoft
true
- browser
\ No newline at end of file
diff --git a/src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.cs b/src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.cs
index da345adb5929c7..794139a4442f5a 100644
--- a/src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.cs
+++ b/src/libraries/System.Net.NetworkInformation/ref/System.Net.NetworkInformation.cs
@@ -6,6 +6,7 @@
namespace System.Net.NetworkInformation
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum DuplicateAddressDetectionState
{
Invalid = 0,
@@ -14,11 +15,13 @@ public enum DuplicateAddressDetectionState
Deprecated = 3,
Preferred = 4,
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class GatewayIPAddressInformation
{
protected GatewayIPAddressInformation() { }
public abstract System.Net.IPAddress Address { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class GatewayIPAddressInformationCollection : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable
{
protected internal GatewayIPAddressInformationCollection() { }
@@ -33,6 +36,7 @@ public virtual void CopyTo(System.Net.NetworkInformation.GatewayIPAddressInforma
public virtual bool Remove(System.Net.NetworkInformation.GatewayIPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IcmpV4Statistics
{
protected IcmpV4Statistics() { }
@@ -79,6 +83,7 @@ protected IcmpV4Statistics() { }
public abstract long TimestampRequestsReceived { get; }
public abstract long TimestampRequestsSent { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IcmpV6Statistics
{
protected IcmpV6Statistics() { }
@@ -131,6 +136,7 @@ protected IcmpV6Statistics() { }
public abstract long TimeExceededMessagesReceived { get; }
public abstract long TimeExceededMessagesSent { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IPAddressInformation
{
protected IPAddressInformation() { }
@@ -140,6 +146,7 @@ protected IPAddressInformation() { }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public abstract bool IsTransient { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class IPAddressInformationCollection : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable
{
internal IPAddressInformationCollection() { }
@@ -154,6 +161,7 @@ public virtual void CopyTo(System.Net.NetworkInformation.IPAddressInformation[]
public virtual bool Remove(System.Net.NetworkInformation.IPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IPGlobalProperties
{
protected IPGlobalProperties() { }
@@ -196,6 +204,7 @@ protected IPGlobalProperties() { }
public virtual System.Net.NetworkInformation.UnicastIPAddressInformationCollection GetUnicastAddresses() { throw null; }
public virtual System.Threading.Tasks.Task GetUnicastAddressesAsync() { throw null; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IPGlobalStatistics
{
protected IPGlobalStatistics() { }
@@ -242,6 +251,7 @@ protected IPGlobalStatistics() { }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
public abstract long ReceivedPacketsWithUnknownProtocol { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IPInterfaceProperties
{
protected IPInterfaceProperties() { }
@@ -278,6 +288,7 @@ protected IPInterfaceProperties() { }
public abstract System.Net.NetworkInformation.IPv4InterfaceProperties GetIPv4Properties();
public abstract System.Net.NetworkInformation.IPv6InterfaceProperties GetIPv6Properties();
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IPInterfaceStatistics
{
protected IPInterfaceStatistics() { }
@@ -300,6 +311,7 @@ protected IPInterfaceStatistics() { }
public abstract long UnicastPacketsReceived { get; }
public abstract long UnicastPacketsSent { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IPv4InterfaceProperties
{
protected IPv4InterfaceProperties() { }
@@ -318,6 +330,7 @@ protected IPv4InterfaceProperties() { }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("linux")]
public abstract bool UsesWins { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IPv4InterfaceStatistics
{
protected IPv4InterfaceStatistics() { }
@@ -338,6 +351,7 @@ protected IPv4InterfaceStatistics() { }
public abstract long UnicastPacketsReceived { get; }
public abstract long UnicastPacketsSent { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IPv6InterfaceProperties
{
protected IPv6InterfaceProperties() { }
@@ -349,6 +363,7 @@ protected IPv6InterfaceProperties() { }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public virtual long GetScopeId(System.Net.NetworkInformation.ScopeLevel scopeLevel) { throw null; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class MulticastIPAddressInformation : System.Net.NetworkInformation.IPAddressInformation
{
protected MulticastIPAddressInformation() { }
@@ -365,6 +380,7 @@ protected MulticastIPAddressInformation() { }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public abstract System.Net.NetworkInformation.SuffixOrigin SuffixOrigin { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class MulticastIPAddressInformationCollection : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable
{
protected internal MulticastIPAddressInformationCollection() { }
@@ -379,6 +395,7 @@ public virtual void CopyTo(System.Net.NetworkInformation.MulticastIPAddressInfor
public virtual bool Remove(System.Net.NetworkInformation.MulticastIPAddressInformation address) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum NetBiosNodeType
{
Unknown = 0,
@@ -401,6 +418,7 @@ public partial class NetworkChange
public NetworkChange() { }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("solaris")]
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static event System.Net.NetworkInformation.NetworkAddressChangedEventHandler? NetworkAddressChanged { add { } remove { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("solaris")]
@@ -419,39 +437,57 @@ protected NetworkInformationException(System.Runtime.Serialization.Serialization
public abstract partial class NetworkInterface
{
protected NetworkInterface() { }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual string Description { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual string Id { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("solaris")]
public static int IPv6LoopbackInterfaceIndex { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual bool IsReceiveOnly { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("solaris")]
public static int LoopbackInterfaceIndex { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual string Name { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual System.Net.NetworkInformation.NetworkInterfaceType NetworkInterfaceType { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual System.Net.NetworkInformation.OperationalStatus OperationalStatus { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual long Speed { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual bool SupportsMulticast { get { throw null; } }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("solaris")]
public static System.Net.NetworkInformation.NetworkInterface[] GetAllNetworkInterfaces() { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual System.Net.NetworkInformation.IPInterfaceProperties GetIPProperties() { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
public virtual System.Net.NetworkInformation.IPInterfaceStatistics GetIPStatistics() { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
public virtual System.Net.NetworkInformation.IPv4InterfaceStatistics GetIPv4Statistics() { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("solaris")]
public static bool GetIsNetworkAvailable() { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual System.Net.NetworkInformation.PhysicalAddress GetPhysicalAddress() { throw null; }
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public virtual bool Supports(System.Net.NetworkInformation.NetworkInterfaceComponent networkInterfaceComponent) { throw null; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum NetworkInterfaceComponent
{
IPv4 = 0,
IPv6 = 1,
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum NetworkInterfaceType
{
Unknown = 1,
@@ -483,6 +519,7 @@ public enum NetworkInterfaceType
Wwanpp = 243,
Wwanpp2 = 244,
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum OperationalStatus
{
Up = 1,
@@ -493,6 +530,7 @@ public enum OperationalStatus
NotPresent = 6,
LowerLayerDown = 7,
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class PhysicalAddress
{
public static readonly System.Net.NetworkInformation.PhysicalAddress None;
@@ -506,6 +544,7 @@ public PhysicalAddress(byte[] address) { }
public static bool TryParse(System.ReadOnlySpan address, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Net.NetworkInformation.PhysicalAddress? value) { throw null; }
public static bool TryParse(string? address, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Net.NetworkInformation.PhysicalAddress? value) { throw null; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum PrefixOrigin
{
Other = 0,
@@ -514,6 +553,7 @@ public enum PrefixOrigin
Dhcp = 3,
RouterAdvertisement = 4,
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum ScopeLevel
{
None = 0,
@@ -525,6 +565,7 @@ public enum ScopeLevel
Organization = 8,
Global = 14,
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum SuffixOrigin
{
Other = 0,
@@ -534,6 +575,7 @@ public enum SuffixOrigin
LinkLayerAddress = 4,
Random = 5,
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class TcpConnectionInformation
{
protected TcpConnectionInformation() { }
@@ -541,6 +583,7 @@ protected TcpConnectionInformation() { }
public abstract System.Net.IPEndPoint RemoteEndPoint { get; }
public abstract System.Net.NetworkInformation.TcpState State { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum TcpState
{
Unknown = 0,
@@ -557,6 +600,7 @@ public enum TcpState
TimeWait = 11,
DeleteTcb = 12,
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class TcpStatistics
{
protected TcpStatistics() { }
@@ -575,6 +619,7 @@ protected TcpStatistics() { }
public abstract long SegmentsResent { get; }
public abstract long SegmentsSent { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class UdpStatistics
{
protected UdpStatistics() { }
@@ -584,6 +629,7 @@ protected UdpStatistics() { }
public abstract long IncomingDatagramsWithErrors { get; }
public abstract int UdpListeners { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class UnicastIPAddressInformation : System.Net.NetworkInformation.IPAddressInformation
{
protected UnicastIPAddressInformation() { }
@@ -602,6 +648,7 @@ protected UnicastIPAddressInformation() { }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public abstract System.Net.NetworkInformation.SuffixOrigin SuffixOrigin { get; }
}
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public partial class UnicastIPAddressInformationCollection : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable
{
protected internal UnicastIPAddressInformationCollection() { }
diff --git a/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj b/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj
index 37cb80afcfa429..2febec989d7b0b 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj
+++ b/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj
@@ -1,7 +1,7 @@
-
+
true
- $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-Solaris;$(NetCoreAppCurrent)
+ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-Android;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-Solaris;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)
@@ -27,7 +27,7 @@
-
+
@@ -48,7 +48,7 @@
-
+
@@ -98,7 +98,7 @@
-
+
@@ -159,6 +159,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BrowserNetworkInterfaceInterop.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BrowserNetworkInterfaceInterop.cs
new file mode 100644
index 00000000000000..f0cf9495b79375
--- /dev/null
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BrowserNetworkInterfaceInterop.cs
@@ -0,0 +1,22 @@
+// 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.InteropServices.JavaScript;
+
+namespace System.Net.NetworkInformation
+{
+ internal static partial class BrowserNetworkInterfaceInterop
+ {
+ [JSImport("INTERNAL.network_wasm_is_online_api_available")]
+ public static partial bool IsApiAvailable();
+
+ [JSImport("INTERNAL.network_wasm_is_online")]
+ public static partial bool IsOnline();
+
+ [JSImport("INTERNAL.network_wasm_set_change_listener")]
+ public static partial void SetChangeListener([JSMarshalAs>] Action handler);
+
+ [JSImport("INTERNAL.network_wasm_remove_change_listener")]
+ public static partial void RemoveChangeListener();
+ }
+}
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/DuplicateAddressDetectionState.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/DuplicateAddressDetectionState.cs
index d51caca2086819..f8e3da168cd05e 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/DuplicateAddressDetectionState.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/DuplicateAddressDetectionState.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Specifies the current state of an IP address.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum DuplicateAddressDetectionState
{
Invalid = 0,
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/GatewayIPAddressInformation.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/GatewayIPAddressInformation.cs
index dfd9113f634fad..2e156d11e8bfa5 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/GatewayIPAddressInformation.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/GatewayIPAddressInformation.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Provides information about a network interface address.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class GatewayIPAddressInformation
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/GatewayIPAddressInformationCollection.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/GatewayIPAddressInformationCollection.cs
index 049419360c2f37..46ae5cd0e9340a 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/GatewayIPAddressInformationCollection.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/GatewayIPAddressInformationCollection.cs
@@ -5,6 +5,7 @@
namespace System.Net.NetworkInformation
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public class GatewayIPAddressInformationCollection : ICollection
{
private readonly List _addresses;
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressInformation.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressInformation.cs
index 87d0f7db9e4ad9..99d7303a4a36fa 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressInformation.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressInformation.cs
@@ -8,6 +8,7 @@ namespace System.Net.NetworkInformation
///
/// Provides information about a network interface address.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class IPAddressInformation
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressInformationCollection.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressInformationCollection.cs
index e0672467f09f33..c3105491710d26 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressInformationCollection.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressInformationCollection.cs
@@ -5,6 +5,7 @@
namespace System.Net.NetworkInformation
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public class IPAddressInformationCollection : ICollection
{
private readonly List _addresses = new List();
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalProperties.cs
index 1a78c1dd3e8b6b..7b588a15c95981 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalProperties.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalProperties.cs
@@ -10,6 +10,7 @@ namespace System.Net.NetworkInformation
/// Provides various global machine properties related to Internet Protocol (IP),
/// such as the local host name, domain name, and active socket connections.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class IPGlobalProperties
{
[UnsupportedOSPlatform("illumos")]
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalPropertiesPal.Browser.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalPropertiesPal.Browser.cs
new file mode 100644
index 00000000000000..f68fb9a5446986
--- /dev/null
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalPropertiesPal.Browser.cs
@@ -0,0 +1,10 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System.Net.NetworkInformation
+{
+ internal static class IPGlobalPropertiesPal
+ {
+ public static IPGlobalProperties GetIPGlobalProperties() => throw new PlatformNotSupportedException();
+ }
+}
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalStatistics.cs
index 04b9f14f1eab2b..17f44d9d2baafa 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalStatistics.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPGlobalStatistics.cs
@@ -8,6 +8,7 @@ namespace System.Net.NetworkInformation
///
/// Provides Internet Protocol (IP) statistical data for the local machine.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class IPGlobalStatistics
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPInterfaceProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPInterfaceProperties.cs
index 33aa2ae654bc28..dc7811758548bb 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPInterfaceProperties.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPInterfaceProperties.cs
@@ -9,6 +9,7 @@ namespace System.Net.NetworkInformation
/// Provides information about a network interface that supports Internet Protocol (IP).
/// such as the addresses assigned to the adapter, and other DNS and routing-related information.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class IPInterfaceProperties
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPInterfaceStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPInterfaceStatistics.cs
index 85e5ef284430be..9fbe3a5953aa1a 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPInterfaceStatistics.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPInterfaceStatistics.cs
@@ -9,6 +9,7 @@ namespace System.Net.NetworkInformation
/// Provides statistics information for a particular network interface,
/// such as the total number of bytes sent and received.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class IPInterfaceStatistics
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPv4InterfaceProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPv4InterfaceProperties.cs
index 687902f08e6659..ad8632fd22defe 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPv4InterfaceProperties.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPv4InterfaceProperties.cs
@@ -8,6 +8,7 @@ namespace System.Net.NetworkInformation
///
/// Provides information about network interfaces that support Internet Protocol (IP) version 4.0.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class IPv4InterfaceProperties
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPv6InterfaceProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPv6InterfaceProperties.cs
index 1e6476017bb515..fb8496a378c6aa 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPv6InterfaceProperties.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPv6InterfaceProperties.cs
@@ -8,6 +8,7 @@ namespace System.Net.NetworkInformation
///
/// Provides information about network interfaces that support Internet Protocol (IP) version 6.0.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class IPv6InterfaceProperties
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IcmpV4Statistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IcmpV4Statistics.cs
index 482db5808aec47..28a8cbb35a6818 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IcmpV4Statistics.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IcmpV4Statistics.cs
@@ -8,6 +8,7 @@ namespace System.Net.NetworkInformation
///
/// Provides Internet Control Message Protocol for IPv4 (ICMPv4) statistical data for the local computer.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class IcmpV4Statistics
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IcmpV6Statistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IcmpV6Statistics.cs
index be51f70d9f296c..35324903916b3e 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IcmpV6Statistics.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IcmpV6Statistics.cs
@@ -8,6 +8,7 @@ namespace System.Net.NetworkInformation
///
/// Provides Internet Control Message Protocol for Internet Protocol version 6 (ICMPv6) statistical data for the local computer.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class IcmpV6Statistics
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/Ipv4InterfaceStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/Ipv4InterfaceStatistics.cs
index 553486796717ff..ffe5fa40af71ee 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/Ipv4InterfaceStatistics.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/Ipv4InterfaceStatistics.cs
@@ -8,6 +8,7 @@ namespace System.Net.NetworkInformation
///
/// Provides statistical data for a network interface on the local computer.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract partial class IPv4InterfaceStatistics
{
protected IPv4InterfaceStatistics() { }
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/MulticastIPAddressInformation.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/MulticastIPAddressInformation.cs
index c16aae4febf6ff..a2fc68adee8d29 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/MulticastIPAddressInformation.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/MulticastIPAddressInformation.cs
@@ -8,6 +8,7 @@ namespace System.Net.NetworkInformation
///
/// Provides information about a network interface's unicast address.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class MulticastIPAddressInformation : IPAddressInformation
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/MulticastIPAddressInformationCollection.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/MulticastIPAddressInformationCollection.cs
index 255d2df4b7fe16..a139a9d5d6e939 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/MulticastIPAddressInformationCollection.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/MulticastIPAddressInformationCollection.cs
@@ -5,6 +5,7 @@
namespace System.Net.NetworkInformation
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public class MulticastIPAddressInformationCollection : ICollection
{
private readonly List _addresses = new List();
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetBiosNodeType.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetBiosNodeType.cs
index 0a27a770a02fd4..68701213e97201 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetBiosNodeType.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetBiosNodeType.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Specifies the Network Basic Input/Output System (NetBIOS) node type.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum NetBiosNodeType
{
Unknown = 0,
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Browser.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Browser.cs
new file mode 100644
index 00000000000000..d76954b1bc00b5
--- /dev/null
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Browser.cs
@@ -0,0 +1,67 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using Microsoft.Win32.SafeHandles;
+
+using System.ComponentModel;
+using System.Collections.Generic;
+using System.Net.Sockets;
+using System.Runtime.Versioning;
+using System.Threading;
+
+namespace System.Net.NetworkInformation
+{
+ // Browser implementation of NetworkChange
+ public partial class NetworkChange
+ {
+ private static event NetworkAvailabilityChangedEventHandler? s_networkAvailabilityChanged;
+
+ [UnsupportedOSPlatform("illumos")]
+ [UnsupportedOSPlatform("solaris")]
+ public static event NetworkAvailabilityChangedEventHandler? NetworkAvailabilityChanged
+ {
+ add
+ {
+ if (!BrowserNetworkInterfaceInterop.IsApiAvailable())
+ throw new System.PlatformNotSupportedException(System.SR.SystemNetNetworkInformation_PlatformNotSupported);
+
+ if (s_networkAvailabilityChanged == null)
+ BrowserNetworkInterfaceInterop.SetChangeListener(OnNetworkAvailabilityChanged);
+
+ s_networkAvailabilityChanged += value;
+ }
+ remove
+ {
+ if (!BrowserNetworkInterfaceInterop.IsApiAvailable())
+ throw new System.PlatformNotSupportedException(System.SR.SystemNetNetworkInformation_PlatformNotSupported);
+
+ s_networkAvailabilityChanged -= value;
+
+ if (s_networkAvailabilityChanged == null)
+ BrowserNetworkInterfaceInterop.RemoveChangeListener();
+ }
+ }
+
+ private static void OnNetworkAvailabilityChanged(bool isOnline) => s_networkAvailabilityChanged?.Invoke(null, new NetworkAvailabilityEventArgs(isOnline));
+
+ [UnsupportedOSPlatform("browser")]
+ [UnsupportedOSPlatform("illumos")]
+ [UnsupportedOSPlatform("solaris")]
+ public static event NetworkAddressChangedEventHandler? NetworkAddressChanged
+ {
+ add => throw new System.PlatformNotSupportedException(System.SR.SystemNetNetworkInformation_PlatformNotSupported);
+ remove => throw new System.PlatformNotSupportedException(System.SR.SystemNetNetworkInformation_PlatformNotSupported);
+ }
+
+ [EditorBrowsableAttribute(EditorBrowsableState.Never)]
+ [Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
+ public NetworkChange()
+ {
+ }
+
+ // Introduced for supporting design-time loading of System.Windows.dll
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
+ public static void RegisterNetworkChange(NetworkChange nc) { }
+ }
+}
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs
index aa456fdfd01b37..150ebe4d5bbdef 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs
@@ -39,6 +39,7 @@ public partial class NetworkChange
private static readonly AutoResetEvent s_runLoopStartedEvent = new AutoResetEvent(false);
private static readonly AutoResetEvent s_runLoopEndedEvent = new AutoResetEvent(false);
+ [UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("illumos")]
[UnsupportedOSPlatform("solaris")]
public static event NetworkAddressChangedEventHandler? NetworkAddressChanged
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs
index ebebfd916dce79..b70c2d53b51172 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs
@@ -44,6 +44,7 @@ private static Socket? Socket
private static Timer? s_availabilityTimer;
private static bool s_availabilityHasChanged;
+ [UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("illumos")]
[UnsupportedOSPlatform("solaris")]
public static event NetworkAddressChangedEventHandler? NetworkAddressChanged
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.UnknownUnix.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.UnknownUnix.cs
index bc0df09d18ac7c..e9b37f1eebfdae 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.UnknownUnix.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.UnknownUnix.cs
@@ -16,6 +16,7 @@ public NetworkChange()
{
}
+ [UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("illumos")]
[UnsupportedOSPlatform("solaris")]
public static event NetworkAddressChangedEventHandler? NetworkAddressChanged
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Windows.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Windows.cs
index a9c2a5ec07745b..51dd23557dddbd 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Windows.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Windows.cs
@@ -28,6 +28,7 @@ public static event NetworkAvailabilityChangedEventHandler? NetworkAvailabilityC
}
}
+ [UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("illumos")]
[UnsupportedOSPlatform("solaris")]
public static event NetworkAddressChangedEventHandler? NetworkAddressChanged
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterface.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterface.cs
index 24f02186c3dc3a..a67b9326f99ddb 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterface.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterface.cs
@@ -11,6 +11,7 @@ public abstract class NetworkInterface
/// Returns objects that describe the network interfaces on the local computer.
///
/// An array of all network interfaces on the local computer.
+ [UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("illumos")]
[UnsupportedOSPlatform("solaris")]
public static NetworkInterface[] GetAllNetworkInterfaces()
@@ -25,6 +26,7 @@ public static bool GetIsNetworkAvailable()
return NetworkInterfacePal.GetIsNetworkAvailable();
}
+ [UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("illumos")]
[UnsupportedOSPlatform("solaris")]
public static int IPv6LoopbackInterfaceIndex
@@ -35,6 +37,7 @@ public static int IPv6LoopbackInterfaceIndex
}
}
+ [UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("illumos")]
[UnsupportedOSPlatform("solaris")]
public static int LoopbackInterfaceIndex
@@ -45,22 +48,26 @@ public static int LoopbackInterfaceIndex
}
}
+ [UnsupportedOSPlatform("browser")]
public virtual string Id { get { throw NotImplemented.ByDesignWithMessage(SR.net_PropertyNotImplementedException); } }
///
/// Gets the name of the network interface.
///
+ [UnsupportedOSPlatform("browser")]
public virtual string Name { get { throw NotImplemented.ByDesignWithMessage(SR.net_PropertyNotImplementedException); } }
///
/// Gets the description of the network interface
///
+ [UnsupportedOSPlatform("browser")]
public virtual string Description { get { throw NotImplemented.ByDesignWithMessage(SR.net_PropertyNotImplementedException); } }
///
/// Gets the IP properties for this network interface.
///
/// The interface's IP properties.
+ [UnsupportedOSPlatform("browser")]
public virtual IPInterfaceProperties GetIPProperties()
{
throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
@@ -70,6 +77,7 @@ public virtual IPInterfaceProperties GetIPProperties()
/// Provides Internet Protocol (IP) statistical data for this network interface.
///
/// The interface's IP statistics.
+ [UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("android")]
public virtual IPInterfaceStatistics GetIPStatistics()
{
@@ -82,6 +90,7 @@ public virtual IPInterfaceStatistics GetIPStatistics()
/// Do not use this method, use GetIPStatistics instead.
///
/// The interface's IP statistics.
+ [UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("android")]
public virtual IPv4InterfaceStatistics GetIPv4Statistics()
{
@@ -91,27 +100,32 @@ public virtual IPv4InterfaceStatistics GetIPv4Statistics()
///
/// Gets the current operational state of the network connection.
///
+ [UnsupportedOSPlatform("browser")]
public virtual OperationalStatus OperationalStatus { get { throw NotImplemented.ByDesignWithMessage(SR.net_PropertyNotImplementedException); } }
///
/// Gets the speed of the interface in bits per second as reported by the interface.
///
+ [UnsupportedOSPlatform("browser")]
public virtual long Speed { get { throw NotImplemented.ByDesignWithMessage(SR.net_PropertyNotImplementedException); } }
///
/// Gets a bool value that indicates whether the network interface is set to only receive data packets.
///
+ [UnsupportedOSPlatform("browser")]
public virtual bool IsReceiveOnly { get { throw NotImplemented.ByDesignWithMessage(SR.net_PropertyNotImplementedException); } }
///
/// Gets a bool value that indicates whether this network interface is enabled to receive multicast packets.
///
+ [UnsupportedOSPlatform("browser")]
public virtual bool SupportsMulticast { get { throw NotImplemented.ByDesignWithMessage(SR.net_PropertyNotImplementedException); } }
///
/// Gets the physical address of this network interface
///
/// The interface's physical address.
+ [UnsupportedOSPlatform("browser")]
public virtual PhysicalAddress GetPhysicalAddress()
{
throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
@@ -120,8 +134,10 @@ public virtual PhysicalAddress GetPhysicalAddress()
///
/// Gets the interface type.
///
+ [UnsupportedOSPlatform("browser")]
public virtual NetworkInterfaceType NetworkInterfaceType { get { throw NotImplemented.ByDesignWithMessage(SR.net_PropertyNotImplementedException); } }
+ [UnsupportedOSPlatform("browser")]
public virtual bool Supports(NetworkInterfaceComponent networkInterfaceComponent)
{
throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException);
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfaceComponent.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfaceComponent.cs
index 4a531878b3bdd6..e60c7b41dc3164 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfaceComponent.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfaceComponent.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Specified the list of Networking components that are supported on a Network Interface
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum NetworkInterfaceComponent
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.Browser.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.Browser.cs
new file mode 100644
index 00000000000000..c7328a34d0e91b
--- /dev/null
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.Browser.cs
@@ -0,0 +1,20 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System.Net.NetworkInformation
+{
+ internal static class NetworkInterfacePal
+ {
+ public static NetworkInterface[] GetAllNetworkInterfaces() => throw new PlatformNotSupportedException();
+ public static int IPv6LoopbackInterfaceIndex => throw new PlatformNotSupportedException();
+ public static int LoopbackInterfaceIndex => throw new PlatformNotSupportedException();
+
+ public static bool GetIsNetworkAvailable()
+ {
+ if (!BrowserNetworkInterfaceInterop.IsApiAvailable())
+ throw new System.PlatformNotSupportedException(System.SR.SystemNetNetworkInformation_PlatformNotSupported);
+
+ return BrowserNetworkInterfaceInterop.IsOnline();
+ }
+ }
+}
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfaceType.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfaceType.cs
index b624bba2b83048..290d10d6b19d3b 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfaceType.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfaceType.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Specifies types of network interfaces.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum NetworkInterfaceType
{
Unknown = 1,
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/OperationalStatus.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/OperationalStatus.cs
index 2c67a43578d44f..ab3e8b616cd3b5 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/OperationalStatus.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/OperationalStatus.cs
@@ -3,6 +3,7 @@
namespace System.Net.NetworkInformation
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum OperationalStatus
{
Up = 1,
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs
index 0bf04e204e8350..7da17158a9febc 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs
@@ -6,6 +6,7 @@
namespace System.Net.NetworkInformation
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public class PhysicalAddress
{
private readonly byte[] _address;
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PrefixOrigin.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PrefixOrigin.cs
index 12275ea8f07a26..b57cb1dc8db45d 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PrefixOrigin.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PrefixOrigin.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Specifies how an IP address network prefix was located.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum PrefixOrigin
{
Other = 0,
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/ScopeLevel.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/ScopeLevel.cs
index 7b4977b83f48e8..9c8cb0b1f50610 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/ScopeLevel.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/ScopeLevel.cs
@@ -4,6 +4,7 @@
namespace System.Net.NetworkInformation
{
// See SCOPE_LEVEL
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum ScopeLevel
{
None = 0,
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SuffixOrigin.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SuffixOrigin.cs
index ff314fe16b7755..99356fd1a3c921 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SuffixOrigin.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SuffixOrigin.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Specifies how an IP address host suffix was located.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum SuffixOrigin
{
Other = 0,
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpConnection.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpConnection.cs
index 5667d7f8ce118f..23ef3bbe49c657 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpConnection.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpConnection.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Provides information about the Transmission Control Protocol (TCP) connections on the local computer.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class TcpConnectionInformation
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpState.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpState.cs
index 94e25952b63315..11c6c99f7a72c9 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpState.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpState.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Specifies the states of a Transmission Control Protocol (TCP) connection.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public enum TcpState
{
Unknown,
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpStatistics.cs
index 1b9dd1a0817ca2..cad82d74e69860 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpStatistics.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/TcpStatistics.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Provides Transmission Control Protocol (TCP) statistical data.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class TcpStatistics
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UdpStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UdpStatistics.cs
index 90d8f4dfb20ffd..ec4c3d55977dd4 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UdpStatistics.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UdpStatistics.cs
@@ -6,6 +6,7 @@ namespace System.Net.NetworkInformation
///
/// Provides User Datagram Protocol (UDP) statistical data.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class UdpStatistics
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnicastIPAddressInformation.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnicastIPAddressInformation.cs
index 139dcc4dce867a..3c726ef34b60f4 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnicastIPAddressInformation.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnicastIPAddressInformation.cs
@@ -10,6 +10,7 @@ namespace System.Net.NetworkInformation
///
/// Provides information about a network interface's unicast address.
///
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class UnicastIPAddressInformation : IPAddressInformation
{
///
diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnicastIPAddressInformationCollection.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnicastIPAddressInformationCollection.cs
index dcca0a443a0bd2..9b805f6c0ae841 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnicastIPAddressInformationCollection.cs
+++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnicastIPAddressInformationCollection.cs
@@ -5,6 +5,7 @@
namespace System.Net.NetworkInformation
{
+ [System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public class UnicastIPAddressInformationCollection : ICollection
{
private readonly List _addresses =
diff --git a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/AssemblyInfo.cs b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/AssemblyInfo.cs
deleted file mode 100644
index 94698a9536f2f9..00000000000000
--- a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/AssemblyInfo.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using Xunit;
-
-[assembly: SkipOnPlatform(TestPlatforms.Browser, "System.Net.NetworkInformation is not supported on Browser")]
diff --git a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs
index b1be503ee4cabf..e74a2c77f8c413 100644
--- a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs
+++ b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs
@@ -12,6 +12,7 @@
namespace System.Net.NetworkInformation.Tests
{
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public class IPGlobalPropertiesTest
{
private readonly ITestOutputHelper _log;
diff --git a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkAddressChangedTests.cs b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkAddressChangedTests.cs
index 6a2a07a81fa0a8..af5a1fe4269ca2 100644
--- a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkAddressChangedTests.cs
+++ b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkAddressChangedTests.cs
@@ -12,6 +12,7 @@ public partial class NetworkChangedTests
private readonly NetworkAddressChangedEventHandler _addressHandler = delegate { };
[Fact]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public void NetworkAddressChanged_AddRemove_Success()
{
NetworkChange.NetworkAddressChanged += _addressHandler;
@@ -19,6 +20,7 @@ public void NetworkAddressChanged_AddRemove_Success()
}
[Fact]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public void NetworkAddressChanged_JustRemove_Success()
{
NetworkChange.NetworkAddressChanged -= _addressHandler;
diff --git a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkAvailabilityChangedTests.cs b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkAvailabilityChangedTests.cs
index 35a19be0b6da0e..e7065176369c08 100644
--- a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkAvailabilityChangedTests.cs
+++ b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkAvailabilityChangedTests.cs
@@ -11,20 +11,31 @@ public partial class NetworkChangedTests
{
private readonly NetworkAvailabilityChangedEventHandler _availabilityHandler = delegate { };
- [Fact]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNotBrowser))]
public void NetworkAvailabilityChanged_AddRemove_Success()
{
NetworkChange.NetworkAvailabilityChanged += _availabilityHandler;
NetworkChange.NetworkAvailabilityChanged -= _availabilityHandler;
}
- [Fact]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJS))]
+ public void NetworkAvailabilityChanged_FailsOnNotSupportedPlatform()
+ {
+ Assert.Throws(() =>
+ {
+ NetworkChange.NetworkAvailabilityChanged += _availabilityHandler;
+ NetworkChange.NetworkAvailabilityChanged -= _availabilityHandler;
+ });
+ }
+
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNotBrowser))]
public void NetworkAvailabilityChanged_JustRemove_Success()
{
NetworkChange.NetworkAvailabilityChanged -= _availabilityHandler;
}
[Fact]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public void NetworkAddressChanged_Add_DoesNotBlock()
{
// Register without unregistering.
@@ -38,6 +49,7 @@ public void NetworkAddressChanged_Add_DoesNotBlock()
}
[Fact]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public void NetworkAddressChanged_AddAndRemove_NetworkAvailabilityChanged_JustRemove_Success()
{
NetworkChange.NetworkAddressChanged += _addressHandler;
@@ -50,6 +62,7 @@ public void NetworkAddressChanged_AddAndRemove_NetworkAvailabilityChanged_JustRe
[InlineData(false, true)]
[InlineData(true, false)]
[InlineData(true, true)]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public void NetworkAvailabilityChanged_NetworkAddressChanged_AddAndRemove_Success(bool addAddressFirst, bool removeAddressFirst)
{
if (addAddressFirst)
diff --git a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkInterfaceBasicTest.cs b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkInterfaceBasicTest.cs
index 4b4a4ad44d9b23..d5666c1dae8a60 100644
--- a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkInterfaceBasicTest.cs
+++ b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkInterfaceBasicTest.cs
@@ -20,6 +20,7 @@ public NetworkInterfaceBasicTest(ITestOutputHelper output)
}
[Fact]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public void BasicTest_GetNetworkInterfaces_AtLeastOne()
{
Assert.NotEqual(0, NetworkInterface.GetAllNetworkInterfaces().Length);
@@ -131,6 +132,7 @@ public void BasicTest_AccessInstanceProperties_NoExceptions_Bsd()
[Fact]
[Trait("IPv4", "true")]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public void BasicTest_StaticLoopbackIndex_MatchesLoopbackNetworkInterface()
{
Assert.True(Capability.IPv4Support());
@@ -154,6 +156,7 @@ public void BasicTest_StaticLoopbackIndex_MatchesLoopbackNetworkInterface()
[Fact]
[Trait("IPv4", "true")]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public void BasicTest_StaticLoopbackIndex_ExceptionIfV4NotSupported()
{
Assert.True(Capability.IPv4Support());
@@ -163,6 +166,7 @@ public void BasicTest_StaticLoopbackIndex_ExceptionIfV4NotSupported()
[Trait("IPv6", "true")]
[ConditionalFact(typeof(Socket), nameof(Socket.OSSupportsIPv6))]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public void BasicTest_StaticIPv6LoopbackIndex_MatchesLoopbackNetworkInterface()
{
Assert.True(Capability.IPv6Support());
@@ -187,6 +191,7 @@ public void BasicTest_StaticIPv6LoopbackIndex_MatchesLoopbackNetworkInterface()
[Trait("IPv6", "true")]
[ConditionalFact(typeof(Socket), nameof(Socket.OSSupportsIPv6))]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public void BasicTest_StaticIPv6LoopbackIndex_ExceptionIfV6NotSupported()
{
Assert.True(Capability.IPv6Support());
@@ -266,17 +271,23 @@ public void BasicTest_GetIPInterfaceStatistics_Success_Bsd()
}
}
-
- [Fact]
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNotBrowser))]
public void BasicTest_GetIsNetworkAvailable_Success()
{
Assert.True(NetworkInterface.GetIsNetworkAvailable());
}
+ [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJS))]
+ public void BasicTest_GetIsNetworkAvailable_FailsOnNotSupportedPlatform()
+ {
+ Assert.Throws(() => NetworkInterface.GetIsNetworkAvailable());
+ }
+
[ConditionalTheory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34690", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[SkipOnPlatform(TestPlatforms.OSX | TestPlatforms.FreeBSD, "Expected behavior is different on OSX or FreeBSD")]
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on Browser, iOS, MacCatalyst, or tvOS.")]
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
[InlineData(false)]
[InlineData(true)]
public async Task NetworkInterface_LoopbackInterfaceIndex_MatchesReceivedPackets(bool ipv6)
diff --git a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkInterfaceIPv4Statistics.cs b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkInterfaceIPv4Statistics.cs
index 43a8e20df7cad9..47c242571daa41 100644
--- a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkInterfaceIPv4Statistics.cs
+++ b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkInterfaceIPv4Statistics.cs
@@ -10,6 +10,7 @@
namespace System.Net.NetworkInformation.Tests
{
+ [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
public class NetworkInterfaceIPv4Statistics
{
private readonly ITestOutputHelper _log;
diff --git a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/System.Net.NetworkInformation.Functional.Tests.csproj b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/System.Net.NetworkInformation.Functional.Tests.csproj
index 345e1f518da3b4..73ae96b77e05ac 100644
--- a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/System.Net.NetworkInformation.Functional.Tests.csproj
+++ b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/System.Net.NetworkInformation.Functional.Tests.csproj
@@ -3,11 +3,9 @@
true
../../src/Resources/Strings.resx
$(NetCoreAppCurrent)
- true
$(DefineConstants);NETWORKINFORMATION_TEST
-
diff --git a/src/libraries/apicompat/ApiCompatBaseline.NetCoreAppLatestStable.txt b/src/libraries/apicompat/ApiCompatBaseline.NetCoreAppLatestStable.txt
index 93dd3423e9b827..bf16d4743473b9 100644
--- a/src/libraries/apicompat/ApiCompatBaseline.NetCoreAppLatestStable.txt
+++ b/src/libraries/apicompat/ApiCompatBaseline.NetCoreAppLatestStable.txt
@@ -46,6 +46,7 @@ CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatfo
CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute' exists on 'System.Linq.EnumerableQuery..ctor(System.Collections.Generic.IEnumerable)' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute' exists on 'System.Linq.EnumerableQuery..ctor(System.Linq.Expressions.Expression)' in the contract but not the implementation.
CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Net.Http.HttpClientHandler.Proxy' changed from '[UnsupportedOSPlatformAttribute("browser")]' in the contract to '[UnsupportedOSPlatformAttribute("browser")]' in the implementation.
+CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()' changed from '[UnsupportedOSPlatformAttribute("illumos")]' in the contract to '[UnsupportedOSPlatformAttribute("browser")]' in the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.CompilerServices.IsReadOnlyAttribute' exists on 'System.Numerics.Vector.CopyTo(System.Span)' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.CompilerServices.IsReadOnlyAttribute' exists on 'System.Numerics.Vector.CopyTo(System.Span)' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.CompilerServices.IsReadOnlyAttribute' exists on 'System.Numerics.Vector.CopyTo(T[])' in the contract but not the implementation.
@@ -107,6 +108,7 @@ CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatfo
Compat issues with assembly System:
CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MaxWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("freebsd")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation.
CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MinWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("freebsd")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation.
+CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()' changed from '[UnsupportedOSPlatformAttribute("illumos")]' in the contract to '[UnsupportedOSPlatformAttribute("browser")]' in the implementation.
CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Security.Cryptography.X509Certificates.PublicKey.GetDSAPublicKey()' changed from '[UnsupportedOSPlatformAttribute("ios")]' in the contract to '[UnsupportedOSPlatformAttribute("browser")]' in the implementation.
Compat issues with assembly System.Core:
CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute' exists on 'System.Linq.EnumerableQuery..ctor(System.Collections.Generic.IEnumerable)' in the contract but not the implementation.
@@ -125,11 +127,15 @@ CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatform
Compat issues with assembly System.IO.FileSystem:
CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.IO.FileStream.Lock(System.Int64, System.Int64)' changed from '[UnsupportedOSPlatformAttribute("ios")]' in the contract to '[UnsupportedOSPlatformAttribute("freebsd")]' in the implementation.
CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.IO.FileStream.Unlock(System.Int64, System.Int64)' changed from '[UnsupportedOSPlatformAttribute("ios")]' in the contract to '[UnsupportedOSPlatformAttribute("freebsd")]' in the implementation.
+Compat issues with assembly System.Net:
+CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()' changed from '[UnsupportedOSPlatformAttribute("illumos")]' in the contract to '[UnsupportedOSPlatformAttribute("browser")]' in the implementation.
Compat issues with assembly System.Linq.Queryable:
CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute' exists on 'System.Linq.EnumerableQuery..ctor(System.Collections.Generic.IEnumerable)' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute' exists on 'System.Linq.EnumerableQuery..ctor(System.Linq.Expressions.Expression)' in the contract but not the implementation.
Compat issues with assembly System.Net.Http:
CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Net.Http.HttpClientHandler.Proxy' changed from '[UnsupportedOSPlatformAttribute("browser")]' in the contract to '[UnsupportedOSPlatformAttribute("browser")]' in the implementation.
+Compat issues with assembly System.Net.NetworkInformation:
+CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()' changed from '[UnsupportedOSPlatformAttribute("illumos")]' in the contract to '[UnsupportedOSPlatformAttribute("browser")]' in the implementation.
Compat issues with assembly System.Net.Security:
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Net.Security.SslCertificateTrust.CreateForX509Collection(System.Security.Cryptography.X509Certificates.X509Certificate2Collection, System.Boolean)' in the contract but not the implementation.
Compat issues with assembly System.Numerics.Vectors:
diff --git a/src/mono/wasm/runtime/exports.ts b/src/mono/wasm/runtime/exports.ts
index e68d942fc0c68c..d581e8446ca6f0 100644
--- a/src/mono/wasm/runtime/exports.ts
+++ b/src/mono/wasm/runtime/exports.ts
@@ -9,6 +9,7 @@ import { ENVIRONMENT_IS_PTHREAD, set_imports_exports } from "./imports";
import { DotnetModule, is_nullish, EarlyImports, EarlyExports, EarlyReplacements, MonoConfig } from "./types";
import { configure_emscripten_startup, mono_wasm_pthread_worker_init } from "./startup";
import { mono_bind_static_method } from "./net6-legacy/method-calls";
+import { network_wasm_is_online, network_wasm_set_change_listener, network_wasm_remove_change_listener, network_wasm_is_online_api_available } from "./network-information";
import { create_weak_ref } from "./weak-ref";
import { export_binding_api, export_mono_api } from "./net6-legacy/exports-legacy";
@@ -148,6 +149,12 @@ function initializeImportsAndExports(
configure_emscripten_startup(module, exportedAPI);
return exportedAPI;
+
+ // NetworkInformation
+ network_wasm_is_online,
+ network_wasm_set_change_listener,
+ network_wasm_remove_change_listener,
+ network_wasm_is_online_api_available
}
diff --git a/src/mono/wasm/runtime/network-information.ts b/src/mono/wasm/runtime/network-information.ts
new file mode 100644
index 00000000000000..64aaee2d304f5f
--- /dev/null
+++ b/src/mono/wasm/runtime/network-information.ts
@@ -0,0 +1,46 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+import { mono_assert } from "./types";
+
+export function network_wasm_is_online(): boolean {
+ mono_assert(network_wasm_is_online_api_available(), "The network_wasm_is_online_api_available is not met");
+ return globalThis.navigator.onLine;
+}
+
+let change_listener: ((onLine: boolean) => void) | null = null;
+
+export function network_wasm_set_change_listener(listener: (onLine: boolean) => void): void {
+ mono_assert(network_wasm_is_online_api_available(), "The network_wasm_is_online_api_available is not met");
+
+ if (!change_listener) {
+ window.addEventListener("offline", network_wasm_available_changed);
+ window.addEventListener("online", network_wasm_available_changed);
+ }
+
+ change_listener = listener;
+}
+
+export function network_wasm_remove_change_listener(): void {
+ mono_assert(network_wasm_is_online_api_available(), "The network_wasm_is_online_api_available is not met");
+
+ if (change_listener) {
+ window.removeEventListener("offline", network_wasm_available_changed);
+ window.removeEventListener("online", network_wasm_available_changed);
+ }
+
+ change_listener = null;
+}
+
+function network_wasm_available_changed() {
+ if (change_listener) {
+ change_listener(network_wasm_is_online());
+ }
+}
+
+export function network_wasm_is_online_api_available(): boolean {
+ return globalThis.navigator
+ && globalThis.window
+ && "onLine" in globalThis.navigator
+ && "addEventListener" in globalThis.window;
+}
\ No newline at end of file