Skip to content

Commit d6c415b

Browse files
pavelsavarajtschuster
authored andcommitted
[WASI] platform specific assemblies and fixes for testing (dotnet#107196)
1 parent 590a0f1 commit d6c415b

File tree

86 files changed

+240
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+240
-86
lines changed

eng/testing/xunit/xunit.console.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
<ItemGroup>
1515
<!-- Configures xunit to not print out passing tests with output when diagnostic messages are enabled. -->
16-
<SetScriptCommands Condition="'$(TargetOS)' == 'windows'" Include="set XUNIT_HIDE_PASSING_OUTPUT_DIAGNOSTICS=1" />
17-
<SetScriptCommands Condition="'$(TargetOS)' != 'windows'" Include="export XUNIT_HIDE_PASSING_OUTPUT_DIAGNOSTICS=1" />
16+
<SetScriptCommands Condition="'$(OS)' != 'Windows_NT'" Include="set XUNIT_HIDE_PASSING_OUTPUT_DIAGNOSTICS=1" />
17+
<SetScriptCommands Condition="'$(OS)' == 'Windows_NT'" Include="export XUNIT_HIDE_PASSING_OUTPUT_DIAGNOSTICS=1" />
1818
</ItemGroup>
1919

2020
<PropertyGroup Condition="'$(BundleXunitRunner)' == 'true'">

src/libraries/Common/src/System/Security/Cryptography/Helpers.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ internal static partial class Helpers
1717
#endif
1818

1919
[UnsupportedOSPlatformGuard("browser")]
20+
[UnsupportedOSPlatformGuard("wasi")]
2021
internal static bool HasSymmetricEncryption { get; } =
2122
#if NET
22-
!OperatingSystem.IsBrowser();
23+
!OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi();
2324
#else
2425
true;
2526
#endif
@@ -35,15 +36,17 @@ internal static partial class Helpers
3536
#if NET
3637
[UnsupportedOSPlatformGuard("android")]
3738
[UnsupportedOSPlatformGuard("browser")]
39+
[UnsupportedOSPlatformGuard("wasi")]
3840
public static bool IsRC2Supported => !OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser();
3941
#else
4042
public static bool IsRC2Supported => true;
4143
#endif
4244

4345
[UnsupportedOSPlatformGuard("browser")]
46+
[UnsupportedOSPlatformGuard("wasi")]
4447
internal static bool HasMD5 { get; } =
4548
#if NET
46-
!OperatingSystem.IsBrowser();
49+
!OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi();
4750
#else
4851
true;
4952
#endif

src/libraries/Common/tests/Common.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
44
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
5-
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx</TargetFrameworks>
5+
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-osx</TargetFrameworks>
66
</PropertyGroup>
77
<ItemGroup>
88
<Compile Include="$(CommonTestPath)System\Collections\DictionaryExtensions.cs"

src/libraries/Common/tests/System/IO/ReparsePointUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static bool CreateSymbolicLink(string linkPath, string targetPath, bool i
7676
#if NETFRAMEWORK
7777
bool isWindows = true;
7878
#else
79-
if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsBrowser()) // OSes that don't support Process.Start()
79+
if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsBrowser() || OperatingSystem.IsWasi()) // OSes that don't support Process.Start()
8080
{
8181
return false;
8282
}

src/libraries/Common/tests/System/Net/Capability.Security.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static partial class Capability
99
{
1010
public static bool IsNtlmInstalled()
1111
{
12-
if (OperatingSystem.IsBrowser())
12+
if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() )
1313
{
1414
return false;
1515
}

src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ public XmlReader CreateDecryptingXmlReader(Stream input, XmlReaderSettings? sett
102102
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
103103
protected virtual XmlReader DecryptDocumentAndCreateXmlReader(XmlDocument document)
104104
{
105+
#if !NETSTANDARD2_1 && !NETSTANDARD2_0 && !NETFRAMEWORK // TODO remove with https://github.com/dotnet/runtime/pull/107185
106+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException();
107+
#else
108+
#pragma warning disable CA1416
109+
#endif
105110
// Perform the actual decryption step, updating the XmlDocument in-place.
106111
EncryptedXml encryptedXml = _encryptedXmlFactory?.Invoke(document) ?? new EncryptedXml(document);
107112
encryptedXml.DecryptDocument();

src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ internal PhysicalFilesWatcher CreateFileWatcher()
164164
FileSystemWatcher? watcher;
165165
#if NET
166166
// For browser/iOS/tvOS we will proactively fallback to polling since FileSystemWatcher is not supported.
167-
if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS())
167+
if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS())
168168
{
169169
UsePollingFileWatcher = true;
170170
UseActivePolling = true;

src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public PhysicalFilesWatcher(
8989
if (fileSystemWatcher != null)
9090
{
9191
#if NET
92-
if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS())
92+
if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS())
9393
{
9494
throw new PlatformNotSupportedException(SR.Format(SR.FileSystemWatcher_PlatformNotSupported, typeof(FileSystemWatcher)));
9595
}
@@ -276,6 +276,7 @@ protected virtual void Dispose(bool disposing)
276276
}
277277

278278
[UnsupportedOSPlatform("browser")]
279+
[UnsupportedOSPlatform("wasi")]
279280
[UnsupportedOSPlatform("ios")]
280281
[UnsupportedOSPlatform("tvos")]
281282
[SupportedOSPlatform("maccatalyst")]
@@ -312,6 +313,7 @@ ex is DirectoryNotFoundException ||
312313
}
313314

314315
[UnsupportedOSPlatform("browser")]
316+
[UnsupportedOSPlatform("wasi")]
315317
[UnsupportedOSPlatform("ios")]
316318
[UnsupportedOSPlatform("tvos")]
317319
[SupportedOSPlatform("maccatalyst")]
@@ -321,6 +323,7 @@ private void OnChanged(object sender, FileSystemEventArgs e)
321323
}
322324

323325
[UnsupportedOSPlatform("browser")]
326+
[UnsupportedOSPlatform("wasi")]
324327
[UnsupportedOSPlatform("ios")]
325328
[UnsupportedOSPlatform("tvos")]
326329
[SupportedOSPlatform("maccatalyst")]
@@ -334,6 +337,7 @@ private void OnError(object sender, ErrorEventArgs e)
334337
}
335338

336339
[UnsupportedOSPlatform("browser")]
340+
[UnsupportedOSPlatform("wasi")]
337341
[UnsupportedOSPlatform("ios")]
338342
[UnsupportedOSPlatform("tvos")]
339343
[SupportedOSPlatform("maccatalyst")]
@@ -360,6 +364,7 @@ ex is SecurityException ||
360364
}
361365

362366
[UnsupportedOSPlatform("browser")]
367+
[UnsupportedOSPlatform("wasi")]
363368
[UnsupportedOSPlatform("ios")]
364369
[UnsupportedOSPlatform("tvos")]
365370
[SupportedOSPlatform("maccatalyst")]
@@ -400,6 +405,7 @@ private void ReportChangeForMatchedEntries(string path)
400405
}
401406

402407
[UnsupportedOSPlatform("browser")]
408+
[UnsupportedOSPlatform("wasi")]
403409
[UnsupportedOSPlatform("ios")]
404410
[UnsupportedOSPlatform("tvos")]
405411
[SupportedOSPlatform("maccatalyst")]
@@ -421,6 +427,7 @@ private void TryDisableFileSystemWatcher()
421427
}
422428

423429
[UnsupportedOSPlatform("browser")]
430+
[UnsupportedOSPlatform("wasi")]
424431
[UnsupportedOSPlatform("ios")]
425432
[UnsupportedOSPlatform("tvos")]
426433
[SupportedOSPlatform("maccatalyst")]

src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public void Notify(ServiceState state)
4141
return;
4242
}
4343

44+
#if !NETSTANDARD2_1 && !NETSTANDARD2_0 && !NETFRAMEWORK // TODO remove with https://github.com/dotnet/runtime/pull/107185
45+
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException();
46+
#else
47+
#pragma warning disable CA1416
48+
#endif
49+
4450
using (var socket = new Socket(AddressFamily.Unix, SocketType.Dgram, ProtocolType.Unspecified))
4551
{
4652
var endPoint = new UnixDomainSocketEndPoint(_socketPath!);

src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.netcoreapp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public partial class HostBuilder
1111
{
1212
private static void AddLifetime(IServiceCollection services)
1313
{
14-
if (!OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser() && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS())
14+
if (!OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi() && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS())
1515
{
1616
services.AddSingleton<IHostLifetime, ConsoleLifetime>();
1717
}

0 commit comments

Comments
 (0)