Skip to content

Commit b779870

Browse files
authored
WASM: Add PlatformNotSupportedException for System.Net.Ping (#39091)
The library isn't supported on WebAssembly.
1 parent 95e3dcc commit b779870

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

src/libraries/System.Net.Ping/src/Resources/Strings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,7 @@
8787
<data name="net_ping_not_supported_uwp" xml:space="preserve">
8888
<value>Ping functionality is not currently supported in UWP.</value>
8989
</data>
90+
<data name="Ping_PlatformNotSupported" xml:space="preserve">
91+
<value>System.Net.Ping is not supported on this platform.</value>
92+
</data>
9093
</root>

src/libraries/System.Net.Ping/src/System.Net.Ping.csproj

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,36 @@
55
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
8-
<ItemGroup>
8+
<PropertyGroup>
9+
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsBrowser)' == 'true'">SR.Ping_PlatformNotSupported</GeneratePlatformNotSupportedAssemblyMessage>
10+
</PropertyGroup>
11+
<ItemGroup Condition="'$(TargetsBrowser)' != 'true'">
912
<Compile Include="System\Net\NetworkInformation\IPStatus.cs" />
1013
<Compile Include="System\Net\NetworkInformation\NetEventSource.Ping.cs" />
1114
<Compile Include="System\Net\NetworkInformation\Ping.cs" />
1215
<Compile Include="System\Net\NetworkInformation\PingCompletedEventArgs.cs" />
1316
<Compile Include="System\Net\NetworkInformation\PingException.cs" />
1417
<Compile Include="System\Net\NetworkInformation\PingOptions.cs" />
1518
<Compile Include="System\Net\NetworkInformation\PingReply.cs" />
16-
</ItemGroup>
17-
<!-- System.Net Common -->
18-
<ItemGroup>
19+
<!-- System.Net Common -->
1920
<Compile Include="$(CommonPath)System\Net\ByteOrder.cs"
2021
Link="Common\System\Net\ByteOrder.cs" />
2122
<Compile Include="$(CommonPath)System\Net\IPAddressParserStatics.cs"
2223
Link="Common\System\Net\IPAddressParserStatics.cs" />
2324
<Compile Include="$(CommonPath)System\Net\SocketAddress.cs"
2425
Link="Common\System\Net\SocketAddress.cs" />
25-
</ItemGroup>
26-
<!-- Logging -->
27-
<ItemGroup>
26+
<!-- Logging -->
2827
<Compile Include="$(CommonPath)System\Net\Logging\NetEventSource.Common.cs"
2928
Link="Common\System\Net\Logging\NetEventSource.Common.cs" />
3029
<Compile Include="$(CommonPath)System\Net\InternalException.cs"
3130
Link="Common\System\Net\InternalException.cs" />
32-
</ItemGroup>
33-
<!-- System.Net.Internals -->
34-
<ItemGroup>
31+
<!-- System.Net.Internals -->
3532
<Compile Include="$(CommonPath)System\Net\Internals\IPAddressExtensions.cs"
3633
Link="Common\System\Net\Internals\IPAddressExtensions.cs" />
3734
<Compile Include="$(CommonPath)System\Net\Internals\IPEndPointExtensions.cs"
3835
Link="Common\System\Net\Internals\IPEndPointExtensions.cs" />
3936
</ItemGroup>
40-
<ItemGroup Condition=" '$(TargetsUnix)' == 'true' or '$(TargetsBrowser)' == 'true' ">
37+
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
4138
<Compile Include="System\Net\NetworkInformation\IcmpV4MessageConstants.cs" />
4239
<Compile Include="System\Net\NetworkInformation\IcmpV6MessageConstants.cs" />
4340
<Compile Include="System\Net\NetworkInformation\Ping.Unix.cs" />
@@ -66,8 +63,6 @@
6663
</ItemGroup>
6764
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
6865
<Compile Include="System\Net\NetworkInformation\Ping.Windows.cs" />
69-
</ItemGroup>
70-
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
7166
<!-- System.Net Common -->
7267
<Compile Include="$(CommonPath)System\Net\SocketAddressPal.Windows.cs"
7368
Link="Common\System\Net\SocketAddressPal.Windows.cs" />
@@ -107,7 +102,7 @@
107102
<Reference Include="System.Threading" />
108103
<Reference Include="System.Threading.ThreadPool" />
109104
</ItemGroup>
110-
<ItemGroup Condition="'$(TargetsUnix)' == 'true' or '$(TargetsBrowser)' == 'true'">
105+
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
111106
<Reference Include="System.Diagnostics.Process" />
112107
<Reference Include="System.IO.FileSystem" />
113108
<Reference Include="System.Runtime.InteropServices.RuntimeInformation" />
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Xunit;
5+
6+
[assembly: SkipOnMono("System.Net.Ping is not supported on Browser", TestPlatforms.Browser)]

src/libraries/System.Net.Ping/tests/FunctionalTests/System.Net.Ping.Functional.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
55
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
6+
<IgnoreForCI Condition="'$(TargetOS)' == 'Browser'">true</IgnoreForCI>
67
</PropertyGroup>
78
<!-- Test APIs introduced after 1.0 -->
89
<ItemGroup>
10+
<Compile Include="AssemblyInfo.cs" />
911
<Compile Include="PingTest.cs" />
1012
<Compile Include="LoggingTest.cs" />
1113
<Compile Include="PingExceptionTest.cs" />

0 commit comments

Comments
 (0)