Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] Mark System.Net.SocketAddress APIs unsupported on Browser #41987

Closed
Closed
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
5 changes: 5 additions & 0 deletions src/libraries/Common/src/System/Net/SocketAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics;
using System.Globalization;
using System.Net.Sockets;
using System.Runtime.Versioning;
using System.Text;

#if SYSTEM_NET_PRIMITIVES_DLL
Expand Down Expand Up @@ -36,6 +37,7 @@ class SocketAddress
private bool _changed = true;
private int _hash;

[UnsupportedOSPlatform("browser")]
public AddressFamily Family
{
get
Expand Down Expand Up @@ -80,10 +82,12 @@ public byte this[int offset]
}
}

[UnsupportedOSPlatform("browser")]
public SocketAddress(AddressFamily family) : this(family, MaxSize)
{
}

[UnsupportedOSPlatform("browser")]
public SocketAddress(AddressFamily family, int size)
{
if (size < MinSize)
Expand Down Expand Up @@ -235,6 +239,7 @@ public override int GetHashCode()
return _hash;
}

[UnsupportedOSPlatform("browser")]
public override string ToString()
{
// Get the address family string. In almost all cases, this should be a cached string
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Net.Primitives/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<IncludePlatformAttributes>true</IncludePlatformAttributes>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public IPEndPoint(System.Net.IPAddress address, int port) { }
public System.Net.IPAddress Address { get { throw null; } set { } }
public override System.Net.Sockets.AddressFamily AddressFamily { get { throw null; } }
public int Port { get { throw null; } set { } }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public override System.Net.EndPoint Create(System.Net.SocketAddress socketAddress) { throw null; }
public override bool Equals(object? comparand) { throw null; }
public override int GetHashCode() { throw null; }
Expand Down Expand Up @@ -308,13 +309,17 @@ public NetworkCredential(string? userName, string? password, string? domain) { }
}
public partial class SocketAddress
{
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public SocketAddress(System.Net.Sockets.AddressFamily family) { }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public SocketAddress(System.Net.Sockets.AddressFamily family, int size) { }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public System.Net.Sockets.AddressFamily Family { get { throw null; } }
public byte this[int offset] { get { throw null; } set { } }
public int Size { get { throw null; } }
public override bool Equals(object? comparand) { throw null; }
public override int GetHashCode() { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public override string ToString() { throw null; }
}
public abstract partial class TransportContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Net.Sockets;
using System.Runtime.Versioning;

namespace System.Net
{
Expand Down Expand Up @@ -154,6 +155,7 @@ public override string ToString()

public override SocketAddress Serialize() => new SocketAddress(Address, Port);

[UnsupportedOSPlatform("browser")]
public override EndPoint Create(SocketAddress socketAddress)
{
if (socketAddress == null)
Expand Down