Skip to content

Commit 0bf688e

Browse files
committed
wip
1 parent c8ae841 commit 0bf688e

20 files changed

+671
-30
lines changed

eng/testing/tests.wasi.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasm --engine-arg=max-wasm-stack=134217728</_XHarnessArgs>
5151
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasi --engine-arg=http</_XHarnessArgs>
5252
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasi --engine-arg=inherit-network</_XHarnessArgs>
53+
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasi --engine-arg=tcp</_XHarnessArgs>
54+
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasi --engine-arg=udp</_XHarnessArgs>
5355
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--wasi --engine-arg=allow-ip-name-lookup</_XHarnessArgs>
5456
<_XHarnessArgs >$(_XHarnessArgs) --engine-arg=--env --engine-arg=DOTNET_WASI_PRINT_EXIT_CODE=1</_XHarnessArgs>
5557
<_XHarnessArgs Condition="'$(WasmXHarnessArgsCli)' != ''" >$(_XHarnessArgs) $(WasmXHarnessArgsCli)</_XHarnessArgs>

src/libraries/Common/src/System/Threading/Tasks/TaskToAsyncResult.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ static class TaskToAsyncResult
3131
/// </remarks>
3232
public static IAsyncResult Begin(Task task, AsyncCallback? callback, object? state)
3333
{
34+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
35+
3436
#if NET
3537
ArgumentNullException.ThrowIfNull(task);
3638
#else

src/libraries/System.Net.Sockets/Directory.Build.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<StrongNameKeyId>Microsoft</StrongNameKeyId>
55
<IncludePlatformAttributes>true</IncludePlatformAttributes>
6-
<!-- WASI until https://github.com/dotnet/runtime/issues/98957 -->
7-
<UnsupportedOSPlatforms>browser;wasi</UnsupportedOSPlatforms>
6+
<UnsupportedOSPlatforms>browser</UnsupportedOSPlatforms>
87
</PropertyGroup>
98
</Project>

src/libraries/System.Net.Sockets/System.Net.Sockets.sln

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35209.166
5+
MinimumVisualStudioVersion = 10.0.40219.1
26
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreamConformanceTests", "..\Common\tests\StreamConformanceTests\StreamConformanceTests.csproj", "{E5699508-7F83-4125-9495-C73BD4C43046}"
37
EndProject
48
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{AEDCC778-C0D1-4155-9DD2-45EBF160CDA0}"
@@ -45,11 +49,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7108F0-035
4549
EndProject
4650
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{51E336C9-CFE7-4459-B407-FD5D9E760D85}"
4751
EndProject
48-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "tools\gen", "{CCBA19A8-17AB-402A-96E6-A1C92784EAC2}"
52+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{CCBA19A8-17AB-402A-96E6-A1C92784EAC2}"
4953
EndProject
50-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "tools\src", "{99B1FC8E-726F-4DBF-887D-38AC7F63C230}"
54+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{99B1FC8E-726F-4DBF-887D-38AC7F63C230}"
5155
EndProject
52-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "tools\ref", "{2D08A54A-C557-444C-9D8D-0BF0E20CDE5A}"
56+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2D08A54A-C557-444C-9D8D-0BF0E20CDE5A}"
5357
EndProject
5458
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{725DA203-1DB5-47D5-991A-8440E254BB23}"
5559
EndProject
@@ -142,28 +146,32 @@ Global
142146
GlobalSection(NestedProjects) = preSolution
143147
{E5699508-7F83-4125-9495-C73BD4C43046} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82}
144148
{AEDCC778-C0D1-4155-9DD2-45EBF160CDA0} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82}
145-
{69A7DCCE-B05B-44F3-B7BC-17A90759D1A2} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82}
146149
{3C5413D5-7662-4E7C-8A1D-C8E6C527782F} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF}
147150
{5BE2193A-9EAB-4F1C-B2F4-E969C84F2614} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF}
148151
{EAEEEA1F-FE18-4CA1-88C9-59CD1097C593} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF}
149152
{FDFDE647-E25F-4B21-B002-4EEEFC42EFA1} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF}
150-
{293F6DBE-2ECA-4F22-AF58-4AC1668F028B} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF}
151-
{F7A848B6-8307-4702-AEEE-20223FB73F29} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF}
152153
{FD313302-FE04-414E-8A62-3BC8894115C1} = {2C7108F0-035E-44A5-8451-FE9535F53D43}
154+
{69A7DCCE-B05B-44F3-B7BC-17A90759D1A2} = {FAD51322-998C-42D4-8FAA-EA479A3A0E82}
153155
{85782EDD-90A7-4600-89EB-4E2C0AAAD446} = {51E336C9-CFE7-4459-B407-FD5D9E760D85}
154156
{B338EB04-67CE-4AD0-A691-A93194B871EF} = {51E336C9-CFE7-4459-B407-FD5D9E760D85}
155157
{0CAE4AA4-2C81-4CA4-978A-F86DD25FA338} = {51E336C9-CFE7-4459-B407-FD5D9E760D85}
156158
{3DD27643-568B-4BA1-82F2-FACFC8365836} = {51E336C9-CFE7-4459-B407-FD5D9E760D85}
159+
{293F6DBE-2ECA-4F22-AF58-4AC1668F028B} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF}
160+
{F7A848B6-8307-4702-AEEE-20223FB73F29} = {FC5FEA3E-33B9-4AEE-8E41-367BB73182EF}
157161
{FA256A4B-476D-4BCA-8E62-C2A11DF778CE} = {CCBA19A8-17AB-402A-96E6-A1C92784EAC2}
158162
{6D7B425E-F07B-4572-98D8-728E3053E30F} = {CCBA19A8-17AB-402A-96E6-A1C92784EAC2}
159-
{CCBA19A8-17AB-402A-96E6-A1C92784EAC2} = {725DA203-1DB5-47D5-991A-8440E254BB23}
160163
{21411575-DD1A-45E1-8B10-6D4EA58684CD} = {99B1FC8E-726F-4DBF-887D-38AC7F63C230}
161164
{FA935CE3-6C83-4993-B565-95DF3129A43B} = {99B1FC8E-726F-4DBF-887D-38AC7F63C230}
162-
{99B1FC8E-726F-4DBF-887D-38AC7F63C230} = {725DA203-1DB5-47D5-991A-8440E254BB23}
163165
{C2011D8C-93D7-486E-8B01-0792262F4EF8} = {2D08A54A-C557-444C-9D8D-0BF0E20CDE5A}
166+
{CCBA19A8-17AB-402A-96E6-A1C92784EAC2} = {725DA203-1DB5-47D5-991A-8440E254BB23}
167+
{99B1FC8E-726F-4DBF-887D-38AC7F63C230} = {725DA203-1DB5-47D5-991A-8440E254BB23}
164168
{2D08A54A-C557-444C-9D8D-0BF0E20CDE5A} = {725DA203-1DB5-47D5-991A-8440E254BB23}
165169
EndGlobalSection
166170
GlobalSection(ExtensibilityGlobals) = postSolution
167171
SolutionGuid = {BA222465-FBD4-4377-8A8A-783BF85E01F7}
168172
EndGlobalSection
173+
GlobalSection(SharedMSBuildProjectFiles) = preSolution
174+
..\..\tools\illink\src\ILLink.Shared\ILLink.Shared.projitems*{6d7b425e-f07b-4572-98d8-728e3053e30f}*SharedItemsImports = 5
175+
..\..\tools\illink\src\ILLink.Shared\ILLink.Shared.projitems*{fa935ce3-6c83-4993-b565-95df3129a43b}*SharedItemsImports = 5
176+
EndGlobalSection
169177
EndGlobal

src/libraries/System.Net.Sockets/src/System.Net.Sockets.csproj

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)</TargetFrameworks>
4+
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)</TargetFrameworks>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<!-- SYSTEM_NET_SOCKETS_DLL is required to allow source-level code sharing for types defined within the
77
System.Net.Internals namespace. -->
@@ -15,6 +15,7 @@
1515
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetPlatformIdentifier)' == ''">SR.SystemNetSockets_PlatformNotSupported</GeneratePlatformNotSupportedAssemblyMessage>
1616
<IsApplePlatform Condition="'$(TargetPlatformIdentifier)' == 'osx' or '$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos'">true</IsApplePlatform>
1717
<DefineConstants Condition="'$(IsApplePlatform)' == 'true'">$(DefineConstants);SYSTEM_NET_SOCKETS_APPLE_PLATFROM</DefineConstants>
18+
<DefineConstants Condition="'$(TargetPlatformIdentifier)' == 'wasi'">$(DefineConstants);TARGET_WASI</DefineConstants>
1819
</PropertyGroup>
1920

2021
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != ''">
@@ -48,7 +49,7 @@
4849
<Compile Include="System\Net\Sockets\TransmitFileOptions.cs" />
4950
<Compile Include="System\Net\Sockets\UDPClient.cs" />
5051
<Compile Include="System\Net\Sockets\UdpReceiveResult.cs" />
51-
<Compile Include="System\Net\Sockets\UnixDomainSocketEndPoint.cs" />
52+
<Compile Include="System\Net\Sockets\UnixDomainSocketEndPoint.cs" Condition="'$(TargetPlatformIdentifier)' != 'wasi'"/>
5253
<!-- Common sources -->
5354
<Compile Include="$(CommonPath)DisableRuntimeMarshalling.cs"
5455
Link="Common\DisableRuntimeMarshalling.cs" />
@@ -184,13 +185,25 @@
184185
</ItemGroup>
185186

186187
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'unix' or '$(TargetPlatformIdentifier)' == 'osx' or '$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos'">
188+
<Compile Include="System\Net\Sockets\UnixDomainSocketEndPoint.Unix.cs"/>
189+
<Compile Include="System\Net\Sockets\SocketAsyncEngine.Unix.cs" />
190+
</ItemGroup>
191+
192+
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'wasi'">
193+
<Compile Include="System\Net\Sockets\UnixDomainSocketEndPoint.Wasi.cs" />
194+
<Compile Include="System\Net\Sockets\SocketAsyncEngine.Wasi.cs"/>
195+
<!--
196+
<Compile Include="System\Net\Sockets\SocketAsyncContext.Wasi.cs" />
197+
-->
198+
</ItemGroup>
199+
200+
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'unix' or '$(TargetPlatformIdentifier)' == 'wasi' or '$(TargetPlatformIdentifier)' == 'osx' or '$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos'">
187201
<Compile Include="System\Net\Sockets\SafeSocketHandle.Unix.cs" />
188202
<Compile Include="System\Net\Sockets\Socket.Unix.cs" />
203+
<Compile Include="System\Net\Sockets\SocketPal.Unix.cs" />
189204
<Compile Include="System\Net\Sockets\SocketAsyncContext.Unix.cs" />
190-
<Compile Include="System\Net\Sockets\SocketAsyncEngine.Unix.cs" />
191205
<Compile Include="System\Net\Sockets\SocketAsyncEventArgs.Unix.cs" />
192-
<Compile Include="System\Net\Sockets\SocketPal.Unix.cs" />
193-
<Compile Include="System\Net\Sockets\UnixDomainSocketEndPoint.Unix.cs" />
206+
194207
<Compile Include="$(CommonPath)System\Net\InteropIPAddressExtensions.Unix.cs"
195208
Link="Common\System\Net\InteropIPAddressExtensions.Unix.cs" />
196209
<Compile Include="$(CommonPath)System\Net\SocketAddressPal.Unix.cs"

src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetworkStream.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ public override long Seek(long offset, SeekOrigin origin)
218218
// Number of bytes we read, or 0 if the socket is closed.
219219
public override int Read(byte[] buffer, int offset, int count)
220220
{
221+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
222+
221223
ValidateBufferArguments(buffer, offset, count);
222224
ThrowIfDisposed();
223225
if (!CanRead)
@@ -237,6 +239,8 @@ public override int Read(byte[] buffer, int offset, int count)
237239

238240
public override int Read(Span<byte> buffer)
239241
{
242+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
243+
240244
if (GetType() != typeof(NetworkStream))
241245
{
242246
// NetworkStream is not sealed, and a derived type may have overridden Read(byte[], int, int) prior
@@ -260,6 +264,8 @@ public override int Read(Span<byte> buffer)
260264

261265
public override unsafe int ReadByte()
262266
{
267+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
268+
263269
byte b;
264270
return Read(new Span<byte>(&b, 1)) == 0 ? -1 : b;
265271
}
@@ -282,6 +288,8 @@ public override unsafe int ReadByte()
282288
// way to indicate an error.
283289
public override void Write(byte[] buffer, int offset, int count)
284290
{
291+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
292+
285293
ValidateBufferArguments(buffer, offset, count);
286294
ThrowIfDisposed();
287295
if (!CanWrite)
@@ -303,6 +311,8 @@ public override void Write(byte[] buffer, int offset, int count)
303311

304312
public override void Write(ReadOnlySpan<byte> buffer)
305313
{
314+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
315+
306316
if (GetType() != typeof(NetworkStream))
307317
{
308318
// NetworkStream is not sealed, and a derived type may have overridden Write(byte[], int, int) prior
@@ -414,6 +424,8 @@ protected override void Dispose(bool disposing)
414424
// An IASyncResult, representing the read.
415425
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
416426
{
427+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
428+
417429
ValidateBufferArguments(buffer, offset, count);
418430
ThrowIfDisposed();
419431
if (!CanRead)
@@ -447,6 +459,8 @@ public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, Asy
447459
// The number of bytes read. May throw an exception.
448460
public override int EndRead(IAsyncResult asyncResult)
449461
{
462+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
463+
450464
ThrowIfDisposed();
451465
ArgumentNullException.ThrowIfNull(asyncResult);
452466

@@ -476,6 +490,8 @@ public override int EndRead(IAsyncResult asyncResult)
476490
// An IASyncResult, representing the write.
477491
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
478492
{
493+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
494+
479495
ValidateBufferArguments(buffer, offset, count);
480496
ThrowIfDisposed();
481497
if (!CanWrite)
@@ -506,6 +522,8 @@ public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, As
506522
// Returns: The number of bytes read. May throw an exception.
507523
public override void EndWrite(IAsyncResult asyncResult)
508524
{
525+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
526+
509527
ThrowIfDisposed();
510528
ArgumentNullException.ThrowIfNull(asyncResult);
511529

0 commit comments

Comments
 (0)