From b085ea5be37a75a52af9c0bdacfffbcf20e3c98f Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 30 Aug 2024 18:43:56 +0200 Subject: [PATCH 01/14] rebase --- eng/testing/xunit/xunit.console.targets | 4 +-- .../System/Security/Cryptography/Helpers.cs | 7 +++-- .../Common/tests/Common.Tests.csproj | 2 +- .../tests/System/IO/ReparsePointUtilities.cs | 2 +- .../System/Net/Capability.Security.Unix.cs | 2 +- ...nsions.Configuration.FileExtensions.csproj | 2 ++ ....Configuration.FileExtensions.Tests.csproj | 2 ++ ...xtensions.Configuration.UserSecrets.csproj | 2 ++ ...ons.Configuration.UserSecrets.Tests.csproj | 2 ++ .../Directory.Build.props | 2 ++ .../Directory.Build.props | 2 ++ .../src/PhysicalFileProvider.cs | 2 +- .../src/PhysicalFilesWatcher.cs | 2 +- .../Directory.Build.props | 2 ++ .../Directory.Build.props | 2 ++ .../src/HostBuilder.netcoreapp.cs | 2 +- .../src/HostingHostBuilderExtensions.cs | 2 +- .../MetricsFactoryHttpMessageHandlerFilter.cs | 2 +- .../System.CodeDom/Directory.Build.props | 2 +- .../ExtendedProtectionPolicyTypeConverter.cs | 2 ++ ...endedProtectionPolicyTypeConverterTests.cs | 1 + .../Directory.Build.props | 2 +- .../System.Data.Odbc/Directory.Build.props | 2 +- .../Diagnostics/Metrics/MetricsEventSource.cs | 4 +-- .../Diagnostics/Metrics/RuntimeMetrics.cs | 4 +-- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Diagnostics/XmlWriterTraceListener.cs | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../System.IO.IsolatedStorage.Tests.csproj | 2 +- .../src/System.IO.MemoryMappedFiles.csproj | 4 +-- .../tests/MemoryMappedFilesTestsBase.Unix.cs | 2 +- .../System.IO.Pipes/Directory.Build.props | 2 +- .../src/System/Linq/ParallelEnumerable.cs | 2 +- .../System.Linq/src/System.Linq.csproj | 2 +- .../src/System.Net.Http.csproj | 25 ++++++++++------ .../BrowserHttpHandler/SocketsHttpHandler.cs | 1 + .../src/System/Net/Http/GlobalHttpSettings.cs | 2 +- .../System/Net/Http/Headers/KnownHeaders.cs | 2 +- .../System/Net/Http/HttpProtocolException.cs | 2 +- .../SocketsHttpHandler/SocketsHttpHandler.cs | 2 +- .../WasiHttpHandler/SystemProxyInfo.Wasi.cs | 10 +++++++ .../tests/FunctionalTests/AssemblyInfo.cs | 2 +- .../System.Net.Http.Functional.Tests.csproj | 1 + .../Directory.Build.props | 2 +- .../src/System.Net.Mail.csproj | 8 ++--- ...tpClient.Browser.cs => SmtpClient.Wasm.cs} | 1 + .../System.Net.Mail.Functional.Tests.csproj | 2 +- .../Directory.Build.props | 2 +- .../src/System.Net.NameResolution.csproj | 6 ++-- .../Directory.Build.props | 2 +- .../System.Net.Ping/Directory.Build.props | 2 +- .../System.Net.Requests/Directory.Build.props | 2 +- .../System.Net.Security/Directory.Build.props | 2 +- .../System.Net.Sockets/Directory.Build.props | 3 +- .../Directory.Build.props | 2 +- .../src/System.Net.WebProxy.csproj | 6 ++-- ...roxy.NonBrowser.cs => WebProxy.NonWasm.cs} | 0 .../{WebProxy.Browser.cs => WebProxy.Wasm.cs} | 0 .../src/System.Net.WebSockets.Client.csproj | 2 ++ .../Win32/SafeHandles/SafeFileHandle.Unix.cs | 2 +- .../Globalization/GlobalizationMode.Unix.cs | 2 +- .../System/Globalization/Normalization.Icu.cs | 2 +- .../System/Threading/ManualResetEventSlim.cs | 3 ++ .../RegisteredWaitHandle.Portable.cs | 3 ++ .../src/System/Threading/SemaphoreSlim.cs | 21 +++++++++++++ .../src/System/Threading/Tasks/Task.cs | 30 +++++++++++++++++++ ...umerableExtensions.ToBlockingEnumerable.cs | 6 ++++ .../src/System/Threading/Thread.cs | 9 ++++++ .../System/Threading/ThreadPoolWorkQueue.cs | 21 +++++++++++++ .../Directory.Build.props | 2 ++ .../Runtime/Caching/HostFileChangeMonitor.cs | 2 +- .../src/System/Runtime/Caching/MemoryCache.cs | 3 +- .../Runtime/Caching/MemoryCacheStatistics.cs | 3 +- .../Runtime/Caching/MemoryCacheStore.cs | 3 +- .../Directory.Build.props | 2 +- .../System/EnvironmentTests.cs | 4 +-- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../src/System.Text.Encodings.Web.csproj | 2 +- .../src/System/Threading/Tasks/Parallel.cs | 2 +- .../System/Threading/Tasks/TaskReplicator.cs | 2 +- src/mono/nuget/mono-packages.proj | 2 ++ src/mono/wasi/runtime/main.c | 1 + .../wasm/host/wasi/WasiEngineArguments.cs | 1 + .../CoreCLRTestLibrary/OutOfProcessTest.cs | 2 +- .../XHarnessRunnerLibrary/RunnerEntryPoint.cs | 4 +-- .../Common/XUnitWrapperGenerator/ITestInfo.cs | 4 +++ .../tracing/eventpipe/common/IpcTraceTest.cs | 2 +- 92 files changed, 236 insertions(+), 85 deletions(-) create mode 100644 src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/SystemProxyInfo.Wasi.cs rename src/libraries/System.Net.Mail/src/System/Net/Mail/{SmtpClient.Browser.cs => SmtpClient.Wasm.cs} (99%) rename src/libraries/System.Net.WebProxy/src/System/Net/{WebProxy.NonBrowser.cs => WebProxy.NonWasm.cs} (100%) rename src/libraries/System.Net.WebProxy/src/System/Net/{WebProxy.Browser.cs => WebProxy.Wasm.cs} (100%) diff --git a/eng/testing/xunit/xunit.console.targets b/eng/testing/xunit/xunit.console.targets index 717ab8ec3460b6..b728c54ed5082d 100644 --- a/eng/testing/xunit/xunit.console.targets +++ b/eng/testing/xunit/xunit.console.targets @@ -13,8 +13,8 @@ - - + + diff --git a/src/libraries/Common/src/System/Security/Cryptography/Helpers.cs b/src/libraries/Common/src/System/Security/Cryptography/Helpers.cs index 341931377ddd8d..d34e3a4884e6a5 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Helpers.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Helpers.cs @@ -17,9 +17,10 @@ internal static partial class Helpers #endif [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("wasi")] internal static bool HasSymmetricEncryption { get; } = #if NET - !OperatingSystem.IsBrowser(); + !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi(); #else true; #endif @@ -35,15 +36,17 @@ internal static partial class Helpers #if NET [UnsupportedOSPlatformGuard("android")] [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("wasi")] public static bool IsRC2Supported => !OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser(); #else public static bool IsRC2Supported => true; #endif [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("wasi")] internal static bool HasMD5 { get; } = #if NET - !OperatingSystem.IsBrowser(); + !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi(); #else true; #endif diff --git a/src/libraries/Common/tests/Common.Tests.csproj b/src/libraries/Common/tests/Common.Tests.csproj index 36ca78878fdb7f..baf24f1232c42e 100644 --- a/src/libraries/Common/tests/Common.Tests.csproj +++ b/src/libraries/Common/tests/Common.Tests.csproj @@ -2,7 +2,7 @@ true true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-osx true true Provides a base class for file-based configuration providers used with Microsoft.Extensions.Configuration and extension methods for configuring them. + + wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/tests/Microsoft.Extensions.Configuration.FileExtensions.Tests.csproj b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/tests/Microsoft.Extensions.Configuration.FileExtensions.Tests.csproj index 9ae3029a16c23a..1c170af7632837 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/tests/Microsoft.Extensions.Configuration.FileExtensions.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/tests/Microsoft.Extensions.Configuration.FileExtensions.Tests.csproj @@ -3,6 +3,8 @@ $(NetCoreAppCurrent);$(NetFrameworkMinimum) true + + wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/Microsoft.Extensions.Configuration.UserSecrets.csproj b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/Microsoft.Extensions.Configuration.UserSecrets.csproj index 4b200df893380c..dd43b41bb8e32e 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/Microsoft.Extensions.Configuration.UserSecrets.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/Microsoft.Extensions.Configuration.UserSecrets.csproj @@ -5,6 +5,8 @@ true true User secrets configuration provider implementation for Microsoft.Extensions.Configuration. User secrets mechanism enables you to override application configuration settings with values stored in the local secrets file. You can use UserSecretsConfigurationExtensions.AddUserSecrets extension method on IConfigurationBuilder to add user secrets provider to the configuration builder. + + wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.csproj b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.csproj index 0964f7795af269..d4b5282eea3458 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.csproj @@ -3,6 +3,8 @@ $(NetCoreAppCurrent);$(NetFrameworkMinimum) true + + wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.Xml/Directory.Build.props index e2a84c6006dc87..9933943952b5ba 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/Directory.Build.props @@ -2,5 +2,7 @@ true + + wasi diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/Directory.Build.props b/src/libraries/Microsoft.Extensions.FileProviders.Physical/Directory.Build.props index 43dc3a2640bbae..d608edfe2846d6 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/Directory.Build.props @@ -2,5 +2,7 @@ true + + wasi diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs index 925df9892752b6..c80d9f32a2c98f 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs @@ -164,7 +164,7 @@ internal PhysicalFilesWatcher CreateFileWatcher() FileSystemWatcher? watcher; #if NET // For browser/iOS/tvOS we will proactively fallback to polling since FileSystemWatcher is not supported. - if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) { UsePollingFileWatcher = true; UseActivePolling = true; diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs index 712a83a3ef2c6e..d160cb8959d179 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs @@ -89,7 +89,7 @@ public PhysicalFilesWatcher( if (fileSystemWatcher != null) { #if NET - if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) { throw new PlatformNotSupportedException(SR.Format(SR.FileSystemWatcher_PlatformNotSupported, typeof(FileSystemWatcher))); } diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props b/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props index 1fa47343884033..3a1d977d49dc3b 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props @@ -3,5 +3,7 @@ hosting true + + wasi diff --git a/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props b/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props index 43dc3a2640bbae..d608edfe2846d6 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props @@ -2,5 +2,7 @@ true + + wasi diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.netcoreapp.cs b/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.netcoreapp.cs index 1407f690de3599..453f92886d3e7f 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.netcoreapp.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.netcoreapp.cs @@ -11,7 +11,7 @@ public partial class HostBuilder { private static void AddLifetime(IServiceCollection services) { - if (!OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser() && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS()) + if (!OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi() && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS()) { services.AddSingleton(); } diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs b/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs index 09274bad3a3cbb..73313d9c0203f3 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/HostingHostBuilderExtensions.cs @@ -293,7 +293,7 @@ internal static void AddDefaultServices(HostBuilderContext hostingContext, IServ logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); #if NET - if (!OperatingSystem.IsBrowser()) + if (!OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi()) #endif { logging.AddConsole(); diff --git a/src/libraries/Microsoft.Extensions.Http/src/MetricsFactoryHttpMessageHandlerFilter.cs b/src/libraries/Microsoft.Extensions.Http/src/MetricsFactoryHttpMessageHandlerFilter.cs index d55f35a2708536..0a9193299f1447 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/MetricsFactoryHttpMessageHandlerFilter.cs +++ b/src/libraries/Microsoft.Extensions.Http/src/MetricsFactoryHttpMessageHandlerFilter.cs @@ -33,7 +33,7 @@ public Action Configure(Action true - browser;ios;tvos;maccatalyst + browser;wasi;ios;tvos;maccatalyst \ No newline at end of file diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs index c918ac07258d00..9672c785a63b11 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverter.cs @@ -21,6 +21,8 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen( [UnsupportedOSPlatform("browser")] public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 + if (destinationType == typeof(InstanceDescriptor)) { if (value is ExtendedProtectionPolicy policy) diff --git a/src/libraries/System.ComponentModel.TypeConverter/tests/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverterTests.cs b/src/libraries/System.ComponentModel.TypeConverter/tests/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverterTests.cs index 82676a7f3f6e89..5a00c40b8daa13 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/tests/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverterTests.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/tests/Security/Authentication/ExtendedProtection/ExtendedProtectionPolicyTypeConverterTests.cs @@ -58,6 +58,7 @@ public void ConvertTo_PositiveTests() [Theory] [SkipOnPlatform(TestPlatforms.Browser, "System.Net.Security is not supported on this platform.")] + [SkipOnPlatform(TestPlatforms.Wasi, "System.Net.Security is not supported on this platform.")] [InlineData(typeof(int))] [InlineData(typeof(ExtendedProtectionPolicy))] [InlineData(typeof(bool))] diff --git a/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props b/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props index c843a6347ce61c..3a3d8f9832479f 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props +++ b/src/libraries/System.Configuration.ConfigurationManager/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Data.Odbc/Directory.Build.props b/src/libraries/System.Data.Odbc/Directory.Build.props index c843a6347ce61c..3a3d8f9832479f 100644 --- a/src/libraries/System.Data.Odbc/Directory.Build.props +++ b/src/libraries/System.Data.Odbc/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs index b6c05113bbc6f2..088295b7377a83 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs @@ -319,7 +319,7 @@ public void OnEventCommand(EventCommandEventArgs command) try { #if OS_ISBROWSER_SUPPORT - if (OperatingSystem.IsBrowser()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi()) { // AggregationManager uses a dedicated thread to avoid losing data for apps experiencing threadpool starvation // and browser doesn't support Thread.Start() @@ -327,7 +327,7 @@ public void OnEventCommand(EventCommandEventArgs command) // This limitation shouldn't really matter because browser also doesn't support out-of-proc EventSource communication // which is the intended scenario for this EventSource. If it matters in the future AggregationManager can be // modified to have some other fallback path that works for browser. - Parent.Error("", "System.Diagnostics.Metrics EventSource not supported on browser"); + Parent.Error("", "System.Diagnostics.Metrics EventSource not supported on browser and wasi"); return; } #endif diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs index 287af3127d7ad1..a9bd6b28665b2b 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs @@ -146,7 +146,7 @@ static RuntimeMetrics() unit: "{cpu}", description: "The number of processors available to the process."); - if (!OperatingSystem.IsBrowser() && !OperatingSystem.IsTvOS() && !(OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst())) + if (!OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi() && !OperatingSystem.IsTvOS() && !(OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst())) { s_meter.CreateObservableCounter( "dotnet.process.cpu.time", @@ -174,7 +174,7 @@ private static IEnumerable> GetGarbageCollectionCounts() [SupportedOSPlatform("maccatalyst")] private static IEnumerable> GetCpuTime() { - Debug.Assert(!OperatingSystem.IsBrowser() && !OperatingSystem.IsTvOS() && !(OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst())); + Debug.Assert(!OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi() &&!OperatingSystem.IsTvOS() && !(OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst())); Environment.ProcessCpuUsage processCpuUsage = Environment.CpuUsage; diff --git a/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props b/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props index ce244cbea56199..58979d42f06955 100644 --- a/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props +++ b/src/libraries/System.Diagnostics.FileVersionInfo/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.Process/Directory.Build.props b/src/libraries/System.Diagnostics.Process/Directory.Build.props index ce244cbea56199..58979d42f06955 100644 --- a/src/libraries/System.Diagnostics.Process/Directory.Build.props +++ b/src/libraries/System.Diagnostics.Process/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs index e5b72a51d41132..068d68e36563db 100644 --- a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs +++ b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/XmlWriterTraceListener.cs @@ -250,7 +250,7 @@ private void WriteEndHeader() string? processName = s_processName; if (processName is null) { - if (OperatingSystem.IsBrowser()) // Process isn't supported on Browser + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() ) // Process isn't supported on Browser { processName = string.Empty; } diff --git a/src/libraries/System.IO.Compression.Brotli/Directory.Build.props b/src/libraries/System.IO.Compression.Brotli/Directory.Build.props index f3f5769f936163..76ee806bc1a2b0 100644 --- a/src/libraries/System.IO.Compression.Brotli/Directory.Build.props +++ b/src/libraries/System.IO.Compression.Brotli/Directory.Build.props @@ -3,6 +3,6 @@ ECMA true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.IO.FileSystem.Watcher/Directory.Build.props b/src/libraries/System.IO.FileSystem.Watcher/Directory.Build.props index c581a9ef9e5a84..a07e665d16a1c1 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/Directory.Build.props +++ b/src/libraries/System.IO.FileSystem.Watcher/Directory.Build.props @@ -3,7 +3,7 @@ Microsoft true - browser;ios;tvos + browser;wasi;ios;tvos maccatalyst \ No newline at end of file diff --git a/src/libraries/System.IO.IsolatedStorage/Directory.Build.props b/src/libraries/System.IO.IsolatedStorage/Directory.Build.props index ce244cbea56199..58979d42f06955 100644 --- a/src/libraries/System.IO.IsolatedStorage/Directory.Build.props +++ b/src/libraries/System.IO.IsolatedStorage/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj index b14e54de417572..0424a4615a07e3 100644 --- a/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj +++ b/src/libraries/System.IO.IsolatedStorage/tests/System.IO.IsolatedStorage.Tests.csproj @@ -1,6 +1,6 @@ - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-android + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-android true diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj index d024cdd7d73110..1710a652f6d6e3 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj +++ b/src/libraries/System.IO.MemoryMappedFiles/src/System.IO.MemoryMappedFiles.csproj @@ -1,7 +1,7 @@ - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) true false @@ -86,7 +86,7 @@ - + Gets the system's page size. protected static Lazy s_pageSize = new Lazy(() => { - if (OperatingSystem.IsBrowser()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi()) return Environment.SystemPageSize; int pageSize; diff --git a/src/libraries/System.IO.Pipes/Directory.Build.props b/src/libraries/System.IO.Pipes/Directory.Build.props index ce244cbea56199..58979d42f06955 100644 --- a/src/libraries/System.IO.Pipes/Directory.Build.props +++ b/src/libraries/System.IO.Pipes/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs index 55ef371ea04226..9f3dc2674aab52 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs @@ -66,7 +66,7 @@ public static class ParallelEnumerable // be executed in parallel, but will retain PLINQ semantics (exceptions wrapped as aggregates, etc). #if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.SupportedOSPlatformGuard("browser")] - internal static bool SinglePartitionMode => OperatingSystem.IsBrowser(); + internal static bool SinglePartitionMode => OperatingSystem.IsBrowser() || OperatingSystem.IsWasi(); #else internal static bool SinglePartitionMode => false; #endif diff --git a/src/libraries/System.Linq/src/System.Linq.csproj b/src/libraries/System.Linq/src/System.Linq.csproj index 68b88631587ace..79c10444f489b2 100644 --- a/src/libraries/System.Linq/src/System.Linq.csproj +++ b/src/libraries/System.Linq/src/System.Linq.csproj @@ -1,7 +1,7 @@ - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos false diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index b924bf22a3dc4e..03123bc5adee2c 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -166,7 +166,7 @@ - + @@ -324,13 +324,13 @@ - + - + @@ -407,7 +407,7 @@ Link="Common\System\Runtime\ExceptionServices\ExceptionStackTrace.cs" /> - + - + @@ -453,7 +453,13 @@ - + + + + + + @@ -491,7 +497,7 @@ - + @@ -499,15 +505,16 @@ + - + - + diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs index 955375e3317933..66b356badc45d4 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs @@ -17,6 +17,7 @@ namespace System.Net.Http public sealed class SocketsHttpHandler : HttpMessageHandler { [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("wasi")] public static bool IsSupported => false; public bool UseCookies diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/GlobalHttpSettings.cs b/src/libraries/System.Net.Http/src/System/Net/Http/GlobalHttpSettings.cs index 72c9a4a3fc52ef..e314957414b6b0 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/GlobalHttpSettings.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/GlobalHttpSettings.cs @@ -23,7 +23,7 @@ internal static class DiagnosticsHandler internal static class SocketsHttpHandler { -#if !BROWSER +#if !TARGET_BROWSER && !TARGET_WASI // Default to allowing HTTP/2, but enable that to be overridden by an // AppContext switch, or by an environment variable being set to false/0. public static bool AllowHttp2 { get; } = RuntimeSettingParser.QueryRuntimeSettingSwitch( diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/KnownHeaders.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/KnownHeaders.cs index ac819868f77683..1b412481a3badc 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/KnownHeaders.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/KnownHeaders.cs @@ -108,7 +108,7 @@ internal static class KnownHeaders public static readonly KnownHeader XUACompatible = new KnownHeader("X-UA-Compatible"); public static readonly KnownHeader XXssProtection = new KnownHeader("X-XSS-Protection", HttpHeaderType.Custom, null, new string[] { "0", "1", "1; mode=block" }); -#if TARGET_BROWSER +#if TARGET_BROWSER || TARGET_WASI private static HttpHeaderParser? GetAltSvcHeaderParser() => null; // Allow for the AltSvcHeaderParser to be trimmed on Browser since Alt-Svc is only for SocketsHttpHandler, which isn't used on Browser. #else private static AltSvcHeaderParser? GetAltSvcHeaderParser() => AltSvcHeaderParser.Parser; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpProtocolException.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpProtocolException.cs index e61ecba6305798..1314f9e3458554 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpProtocolException.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpProtocolException.cs @@ -35,7 +35,7 @@ public HttpProtocolException(long errorCode, string message, Exception? innerExc /// public long ErrorCode { get; } -#if !TARGET_BROWSER +#if !TARGET_BROWSER && !TARGET_WASI internal static HttpProtocolException CreateHttp2StreamException(Http2ProtocolErrorCode protocolError) { string message = SR.Format(SR.net_http_http2_stream_error, GetName(protocolError), ((int)protocolError).ToString("x")); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs index 44acad742e7c21..6c0a8208508bdb 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs @@ -36,7 +36,7 @@ private void CheckDisposedOrStarted() /// Gets a value that indicates whether the handler is supported on the current platform. /// [UnsupportedOSPlatformGuard("browser")] - public static bool IsSupported => !OperatingSystem.IsBrowser(); + public static bool IsSupported => !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi(); public bool UseCookies { diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/SystemProxyInfo.Wasi.cs b/src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/SystemProxyInfo.Wasi.cs new file mode 100644 index 00000000000000..845223cdf32266 --- /dev/null +++ b/src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/SystemProxyInfo.Wasi.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.Http +{ + internal static partial class SystemProxyInfo + { + public static IWebProxy Proxy => new HttpNoProxy(); + } +} diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/AssemblyInfo.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/AssemblyInfo.cs index 386a384e486f10..bf269b513f000a 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/AssemblyInfo.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/AssemblyInfo.cs @@ -5,5 +5,5 @@ using Xunit; [assembly: SkipOnCoreClr("System.Net.Tests are flaky and/or long running: https://github.com/dotnet/runtime/issues/131", ~RuntimeConfiguration.Release)] -[assembly: ActiveIssue("https://github.com/dotnet/runtime/issues/131", ~(TestPlatforms.Android | TestPlatforms.Browser), TargetFrameworkMonikers.Any, TestRuntimes.Mono)] // System.Net.Tests are flaky and/or long running +[assembly: ActiveIssue("https://github.com/dotnet/runtime/issues/131", ~(TestPlatforms.Android | TestPlatforms.Browser | TestPlatforms.Wasi), TargetFrameworkMonikers.Any, TestRuntimes.Mono)] // System.Net.Tests are flaky and/or long running diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj index eb8e53ac574cea..b14c7411169b38 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj @@ -32,6 +32,7 @@ WasmTestOnWasmtime $(DefineConstants);TARGET_WASI + true diff --git a/src/libraries/System.Net.HttpListener/Directory.Build.props b/src/libraries/System.Net.HttpListener/Directory.Build.props index c843a6347ce61c..3a3d8f9832479f 100644 --- a/src/libraries/System.Net.HttpListener/Directory.Build.props +++ b/src/libraries/System.Net.HttpListener/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index c07188adcd018d..f79d691669c15f 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -1,7 +1,7 @@  - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) true false @@ -84,12 +84,12 @@ Link="Common\System\Obsoletions.cs" /> - - + + - + diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Wasm.cs similarity index 99% rename from src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs rename to src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Wasm.cs index b8b9c08b4cd65f..efed4be0ab56e2 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Browser.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Wasm.cs @@ -28,6 +28,7 @@ public enum SmtpDeliveryFormat } [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] public class SmtpClient : IDisposable { #pragma warning disable CS0067 // Field is not used diff --git a/src/libraries/System.Net.Mail/tests/Functional/System.Net.Mail.Functional.Tests.csproj b/src/libraries/System.Net.Mail/tests/Functional/System.Net.Mail.Functional.Tests.csproj index 7336f9199077a7..28ea42dedc3795 100644 --- a/src/libraries/System.Net.Mail/tests/Functional/System.Net.Mail.Functional.Tests.csproj +++ b/src/libraries/System.Net.Mail/tests/Functional/System.Net.Mail.Functional.Tests.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-android + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-android true true true diff --git a/src/libraries/System.Net.NameResolution/Directory.Build.props b/src/libraries/System.Net.NameResolution/Directory.Build.props index ce244cbea56199..58979d42f06955 100644 --- a/src/libraries/System.Net.NameResolution/Directory.Build.props +++ b/src/libraries/System.Net.NameResolution/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 5d97e2d711f31b..41dccf89ade000 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -1,7 +1,7 @@ - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent) + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent) true false @@ -9,8 +9,8 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - SR.SystemNetNameResolution_PlatformNotSupported - ExcludeApiList.PNSE.Browser.txt + SR.SystemNetNameResolution_PlatformNotSupported + ExcludeApiList.PNSE.Wasm.txt diff --git a/src/libraries/System.Net.NetworkInformation/Directory.Build.props b/src/libraries/System.Net.NetworkInformation/Directory.Build.props index ce244cbea56199..58979d42f06955 100644 --- a/src/libraries/System.Net.NetworkInformation/Directory.Build.props +++ b/src/libraries/System.Net.NetworkInformation/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Ping/Directory.Build.props b/src/libraries/System.Net.Ping/Directory.Build.props index ce244cbea56199..58979d42f06955 100644 --- a/src/libraries/System.Net.Ping/Directory.Build.props +++ b/src/libraries/System.Net.Ping/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Requests/Directory.Build.props b/src/libraries/System.Net.Requests/Directory.Build.props index ce244cbea56199..58979d42f06955 100644 --- a/src/libraries/System.Net.Requests/Directory.Build.props +++ b/src/libraries/System.Net.Requests/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Security/Directory.Build.props b/src/libraries/System.Net.Security/Directory.Build.props index ce244cbea56199..58979d42f06955 100644 --- a/src/libraries/System.Net.Security/Directory.Build.props +++ b/src/libraries/System.Net.Security/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Sockets/Directory.Build.props b/src/libraries/System.Net.Sockets/Directory.Build.props index ce244cbea56199..f58ea59921f19f 100644 --- a/src/libraries/System.Net.Sockets/Directory.Build.props +++ b/src/libraries/System.Net.Sockets/Directory.Build.props @@ -3,6 +3,7 @@ Microsoft true - browser + + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.WebClient/Directory.Build.props b/src/libraries/System.Net.WebClient/Directory.Build.props index c843a6347ce61c..3a3d8f9832479f 100644 --- a/src/libraries/System.Net.WebClient/Directory.Build.props +++ b/src/libraries/System.Net.WebClient/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj index ef670932cb9143..f23c6072c4df7a 100644 --- a/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj +++ b/src/libraries/System.Net.WebProxy/src/System.Net.WebProxy.csproj @@ -1,7 +1,7 @@ - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi true false @@ -10,8 +10,8 @@ - - + + diff --git a/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.NonBrowser.cs b/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.NonWasm.cs similarity index 100% rename from src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.NonBrowser.cs rename to src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.NonWasm.cs diff --git a/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.Browser.cs b/src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.Wasm.cs similarity index 100% rename from src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.Browser.cs rename to src/libraries/System.Net.WebProxy/src/System/Net/WebProxy.Wasm.cs diff --git a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj index 8265edd7e9369a..3b68c3da977eb6 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj +++ b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj @@ -4,6 +4,8 @@ $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser True false + + wasi diff --git a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs index 4029e70cef29e8..476af77370bd66 100644 --- a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs @@ -34,7 +34,7 @@ public sealed partial class SafeFileHandle : SafeHandleZeroOrMinusOneIsInvalid UnixFileMode.OtherRead | UnixFileMode.OtherWrite; - internal static bool DisableFileLocking { get; } = OperatingSystem.IsBrowser() // #40065: Emscripten does not support file locking + internal static bool DisableFileLocking { get; } = OperatingSystem.IsBrowser() || OperatingSystem.IsWasi()// #40065: Emscripten does not support file locking || AppContextConfigHelper.GetBooleanConfig("System.IO.DisableFileLocking", "DOTNET_SYSTEM_IO_DISABLEFILELOCKING", defaultValue: false); // not using bool? as it's not thread safe diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs index df937e56e34fee..edc529fba01dda 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs @@ -38,7 +38,7 @@ static Settings() private static string GetIcuLoadFailureMessage() { // These strings can't go into resources, because a resource lookup requires globalization, which requires ICU - if (OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS()) { return "Unable to load required ICU Globalization data. Please see https://aka.ms/dotnet-missing-libicu for more information"; diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs index 20ef88d4401901..6ef9df95aa79d4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs @@ -118,7 +118,7 @@ private static void ValidateArguments(string strInput, NormalizationForm normali { Debug.Assert(strInput != null); - if (OperatingSystem.IsBrowser() && (normalizationForm == NormalizationForm.FormKC || normalizationForm == NormalizationForm.FormKD)) + if ((OperatingSystem.IsBrowser() || OperatingSystem.IsWasi())&& (normalizationForm == NormalizationForm.FormKC || normalizationForm == NormalizationForm.FormKD)) { // Browser's ICU doesn't contain data needed for FormKC and FormKD throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs index 37f8c06af04565..a9b8c10c03318d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs @@ -350,6 +350,9 @@ public void Reset() #endif public void Wait() { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif Wait(Timeout.Infinite, CancellationToken.None); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs index 2fb8d1fb3f63ca..74dbefe5869067 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs @@ -55,6 +55,9 @@ public sealed partial class RegisteredWaitHandle : MarshalByRefObject internal RegisteredWaitHandle(WaitHandle waitHandle, _ThreadPoolWaitOrTimerCallback callbackHelper, int millisecondsTimeout, bool repeating) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif #if WINDOWS Debug.Assert(!ThreadPool.UseWindowsThreadPool); #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs index 5340ecaeccc50a..bab6bbd332b19a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs @@ -174,6 +174,9 @@ public SemaphoreSlim(int initialCount, int maxCount) [UnsupportedOSPlatform("browser")] public void Wait() { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif // Call wait with infinite timeout Wait(Timeout.Infinite, CancellationToken.None); } @@ -191,6 +194,9 @@ public void Wait() [UnsupportedOSPlatform("browser")] public void Wait(CancellationToken cancellationToken) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif // Call wait with infinite timeout Wait(Timeout.Infinite, cancellationToken); } @@ -210,6 +216,9 @@ public void Wait(CancellationToken cancellationToken) [UnsupportedOSPlatform("browser")] public bool Wait(TimeSpan timeout) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif // Validate the timeout long totalMilliseconds = (long)timeout.TotalMilliseconds; if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue) @@ -241,6 +250,9 @@ public bool Wait(TimeSpan timeout) [UnsupportedOSPlatform("browser")] public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif // Validate the timeout long totalMilliseconds = (long)timeout.TotalMilliseconds; if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue) @@ -266,6 +278,9 @@ public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) [UnsupportedOSPlatform("browser")] public bool Wait(int millisecondsTimeout) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif return Wait(millisecondsTimeout, CancellationToken.None); } @@ -284,6 +299,9 @@ public bool Wait(int millisecondsTimeout) [UnsupportedOSPlatform("browser")] public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif CheckDispose(); #if FEATURE_WASM_MANAGED_THREADS Thread.AssureBlockingPossible(); @@ -433,6 +451,9 @@ public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) [UnsupportedOSPlatform("browser")] private bool WaitUntilCountOrTimeout(int millisecondsTimeout, uint startTime, CancellationToken cancellationToken) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif int remainingWaitMilliseconds = Timeout.Infinite; // Wait on the monitor as long as the count is zero diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs index 0febf7376f39f9..a6acc125c038b5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @@ -2967,6 +2967,9 @@ internal bool InternalWait(int millisecondsTimeout, CancellationToken cancellati // to be able to see the method on the stack and inspect arguments). private bool InternalWaitCore(int millisecondsTimeout, CancellationToken cancellationToken) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif // If the task has already completed, there's nothing to wait for. bool returnValue = IsCompleted; if (returnValue) @@ -4682,6 +4685,9 @@ internal void RemoveContinuation(object continuationObject) // could be TaskCont [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static void WaitAll(params Task[] tasks) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif if (tasks is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks); @@ -4707,6 +4713,9 @@ public static void WaitAll(params Task[] tasks) [UnsupportedOSPlatform("browser")] public static void WaitAll(params ReadOnlySpan tasks) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif bool waitResult = WaitAllCore(tasks, Timeout.Infinite, default); Debug.Assert(waitResult, "expected wait to succeed"); } @@ -4744,6 +4753,9 @@ public static void WaitAll(params ReadOnlySpan tasks) [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static bool WaitAll(Task[] tasks, TimeSpan timeout) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif long totalMilliseconds = (long)timeout.TotalMilliseconds; if (totalMilliseconds is < -1 or > int.MaxValue) { @@ -4788,6 +4800,9 @@ public static bool WaitAll(Task[] tasks, TimeSpan timeout) [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static bool WaitAll(Task[] tasks, int millisecondsTimeout) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif if (tasks is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks); @@ -4822,6 +4837,9 @@ public static bool WaitAll(Task[] tasks, int millisecondsTimeout) [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static void WaitAll(Task[] tasks, CancellationToken cancellationToken) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif if (tasks is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks); @@ -4868,6 +4886,9 @@ public static void WaitAll(Task[] tasks, CancellationToken cancellationToken) [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static bool WaitAll(Task[] tasks, int millisecondsTimeout, CancellationToken cancellationToken) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif if (tasks is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks); @@ -4890,6 +4911,9 @@ public static bool WaitAll(Task[] tasks, int millisecondsTimeout, CancellationTo [UnsupportedOSPlatform("browser")] public static void WaitAll(IEnumerable tasks, CancellationToken cancellationToken = default) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif if (tasks is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks); @@ -4908,6 +4932,9 @@ public static void WaitAll(IEnumerable tasks, CancellationToken cancellati [UnsupportedOSPlatform("browser")] private static bool WaitAllCore(ReadOnlySpan tasks, int millisecondsTimeout, CancellationToken cancellationToken) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif if (millisecondsTimeout < -1) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.millisecondsTimeout); @@ -5038,6 +5065,9 @@ private static void AddToList(T item, ref List? list, int initSize) [UnsupportedOSPlatform("browser")] private static bool WaitAllBlockingCore(List tasks, int millisecondsTimeout, CancellationToken cancellationToken) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif Debug.Assert(tasks != null, "Expected a non-null list of tasks"); Debug.Assert(tasks.Count > 0, "Expected at least one task"); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.ToBlockingEnumerable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.ToBlockingEnumerable.cs index 4c165a913929a2..2b66d88540b1b6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.ToBlockingEnumerable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskAsyncEnumerableExtensions.ToBlockingEnumerable.cs @@ -26,6 +26,9 @@ public static partial class TaskAsyncEnumerableExtensions [UnsupportedOSPlatform("browser")] public static IEnumerable ToBlockingEnumerable(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif IAsyncEnumerator enumerator = source.GetAsyncEnumerator(cancellationToken); // A ManualResetEventSlim variant that lets us reuse the same // awaiter callback allocation across the entire enumeration. @@ -79,6 +82,9 @@ public ManualResetEventWithAwaiterSupport() [UnsupportedOSPlatform("browser")] public void Wait(TAwaiter awaiter) where TAwaiter : ICriticalNotifyCompletion { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif awaiter.UnsafeOnCompleted(_onCompleted); Wait(); Reset(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs index 7af434b641a34c..ed4aaf75758075 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs @@ -149,15 +149,21 @@ public Thread(ParameterizedThreadStart start, int maxStackSize) } #if (!TARGET_BROWSER && !TARGET_WASI) || FEATURE_WASM_MANAGED_THREADS + [UnsupportedOSPlatformGuard("wasi")] [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("wasi")] internal static bool IsThreadStartSupported => true; internal static bool IsInternalThreadStartSupported => true; #elif FEATURE_WASM_PERFTRACING + [UnsupportedOSPlatformGuard("wasi")] [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("wasi")] internal static bool IsThreadStartSupported => false; internal static bool IsInternalThreadStartSupported => true; #else + [UnsupportedOSPlatformGuard("wasi")] [UnsupportedOSPlatformGuard("browser")] + [UnsupportedOSPlatformGuard("wasi")] internal static bool IsThreadStartSupported => false; internal static bool IsInternalThreadStartSupported => false; #endif @@ -197,6 +203,9 @@ internal static void ThrowIfNoThreadStart(bool internalThread = false) private void Start(object? parameter, bool captureContext, bool internalThread = false) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif ThrowIfNoThreadStart(internalThread); StartHelper? startHelper = _startHelper; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs index 89dac7492578fd..279932486e58a6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs @@ -1624,6 +1624,9 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif if (millisecondsTimeOutInterval > (uint)int.MaxValue && millisecondsTimeOutInterval != uint.MaxValue) throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_LessEqualToIntegerMaxVal); return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, true); @@ -1641,6 +1644,9 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif if (millisecondsTimeOutInterval > (uint)int.MaxValue && millisecondsTimeOutInterval != uint.MaxValue) throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, false); @@ -1672,6 +1678,9 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif ArgumentOutOfRangeException.ThrowIfLessThan(millisecondsTimeOutInterval, -1); return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, false); } @@ -1687,6 +1696,9 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif ArgumentOutOfRangeException.ThrowIfLessThan(millisecondsTimeOutInterval, -1); ArgumentOutOfRangeException.ThrowIfGreaterThan(millisecondsTimeOutInterval, int.MaxValue); return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, true); @@ -1703,6 +1715,9 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif ArgumentOutOfRangeException.ThrowIfLessThan(millisecondsTimeOutInterval, -1); ArgumentOutOfRangeException.ThrowIfGreaterThan(millisecondsTimeOutInterval, int.MaxValue); return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, false); @@ -1719,6 +1734,9 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( bool executeOnlyOnce ) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif long tm = (long)timeout.TotalMilliseconds; ArgumentOutOfRangeException.ThrowIfLessThan(tm, -1, nameof(timeout)); @@ -1738,6 +1756,9 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( bool executeOnlyOnce ) { +#if TARGET_WASI + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#endif long tm = (long)timeout.TotalMilliseconds; ArgumentOutOfRangeException.ThrowIfLessThan(tm, -1, nameof(timeout)); diff --git a/src/libraries/System.Runtime.Caching/Directory.Build.props b/src/libraries/System.Runtime.Caching/Directory.Build.props index d68d22c1b917f8..0232329ad312aa 100644 --- a/src/libraries/System.Runtime.Caching/Directory.Build.props +++ b/src/libraries/System.Runtime.Caching/Directory.Build.props @@ -3,5 +3,7 @@ Microsoft true + + wasi \ No newline at end of file diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/HostFileChangeMonitor.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/HostFileChangeMonitor.cs index 374ff288ea0bbe..c14de7b5d2cad1 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/HostFileChangeMonitor.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/HostFileChangeMonitor.cs @@ -99,7 +99,7 @@ private static void InitFCN() if (fcn == null) { #if NET - if (OperatingSystem.IsBrowser() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() || (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS()) { throw new PlatformNotSupportedException(); } diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs index aed16512d0da72..5ec63c2f65e07b 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCache.cs @@ -39,8 +39,9 @@ public class MemoryCache : ObjectCache, IEnumerable, IDisposable private bool _useMemoryCacheManager = true; private bool _throwOnDisposed; #if NET + [UnsupportedOSPlatformGuard("wasi")] [UnsupportedOSPlatformGuard("browser")] - private static bool _countersSupported => !OperatingSystem.IsBrowser(); + private static bool _countersSupported => !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi(); #else private static bool _countersSupported => true; #endif diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStatistics.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStatistics.cs index dba747c4acdfe5..634270e09a9daa 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStatistics.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStatistics.cs @@ -38,8 +38,9 @@ internal sealed class MemoryCacheStatistics : IDisposable private readonly MemoryCache _memoryCache; private readonly PhysicalMemoryMonitor _physicalMemoryMonitor; #if NET + [UnsupportedOSPlatformGuard("wasi")] [UnsupportedOSPlatformGuard("browser")] - private static bool _configSupported => !OperatingSystem.IsBrowser(); + private static bool _configSupported => !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi(); #else private static bool _configSupported => true; #endif diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStore.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStore.cs index 146935b54bafa0..24a9821a75c88e 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStore.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryCacheStore.cs @@ -27,8 +27,9 @@ internal sealed class MemoryCacheStore : IDisposable private readonly MemoryCache _cache; private readonly Counters _perfCounters; #if NET + [UnsupportedOSPlatformGuard("wasi")] [UnsupportedOSPlatformGuard("browser")] - private static bool _countersSupported => !OperatingSystem.IsBrowser(); + private static bool _countersSupported => !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi(); #else private static bool _countersSupported => true; #endif diff --git a/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props b/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props index e7d357018da7bf..7d407028f6632b 100644 --- a/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props +++ b/src/libraries/System.Runtime.Serialization.Schema/Directory.Build.props @@ -4,6 +4,6 @@ Microsoft true - browser;ios;tvos;maccatalyst + browser;wasi;ios;tvos;maccatalyst diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/EnvironmentTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/EnvironmentTests.cs index 7965f9598bfd33..6d8e5372051759 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/EnvironmentTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/EnvironmentTests.cs @@ -139,7 +139,7 @@ public void OSVersion_Idempotent() public void OSVersion_MatchesPlatform() { PlatformID id = Environment.OSVersion.Platform; - PlatformID expected = OperatingSystem.IsWindows() ? PlatformID.Win32NT : OperatingSystem.IsBrowser() ? PlatformID.Other : PlatformID.Unix; + PlatformID expected = OperatingSystem.IsWindows() ? PlatformID.Win32NT : (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi()) ? PlatformID.Other : PlatformID.Unix; Assert.Equal(expected, id); } @@ -154,7 +154,7 @@ public void OSVersion_ValidVersion() Assert.Contains(version.ToString(2), versionString); - string expectedOS = OperatingSystem.IsWindows() ? "Windows " : OperatingSystem.IsBrowser() ? "Other " : "Unix "; + string expectedOS = OperatingSystem.IsWindows() ? "Windows " : (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi()) ? "Other " : "Unix "; Assert.Contains(expectedOS, versionString); } diff --git a/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props b/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props index c4db04cc6c252f..d13e60dc1f0132 100644 --- a/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Cose/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi diff --git a/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props b/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props index 1f799d605feb93..e3cd1bcddea8ee 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Pkcs/Directory.Build.props @@ -3,6 +3,6 @@ Microsoft true - browser + browser;wasi diff --git a/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props b/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props index c843a6347ce61c..3a3d8f9832479f 100644 --- a/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props +++ b/src/libraries/System.Security.Cryptography.Xml/Directory.Build.props @@ -2,6 +2,6 @@ true - browser + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj index 4f10f6e625453d..2fba3b5e13bd6f 100644 --- a/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj +++ b/src/libraries/System.Text.Encodings.Web/src/System.Text.Encodings.Web.csproj @@ -1,7 +1,7 @@ - $(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-browser;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + $(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-browser;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) $(TargetFrameworks);$(NetCoreAppPrevious)-windows;$(NetCoreAppPrevious) true diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs index 7a466d0501c2a0..eadc4bc1ba659f 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs +++ b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs @@ -240,7 +240,7 @@ public static void Invoke(ParallelOptions parallelOptions, params Action[] actio #if !FEATURE_WASM_MANAGED_THREADS // Web browsers need special treatment that is implemented in TaskReplicator - if (OperatingSystem.IsBrowser() || + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() || #else if ( #endif diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs index 0239770284e4ac..5090a6bd17dbc4 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs +++ b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs @@ -132,7 +132,7 @@ public static void Run(ReplicatableUserAction action, ParallelOp // Browser hosts do not support synchronous Wait so we want to run the // replicated task directly instead of going through Task infrastructure #if !FEATURE_WASM_MANAGED_THREADS - if (OperatingSystem.IsBrowser()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() ) { // Since we are running on a single thread, we don't want the action to time out long timeout = long.MaxValue - 1; diff --git a/src/mono/nuget/mono-packages.proj b/src/mono/nuget/mono-packages.proj index 4e119edcafa1d7..9c8dbbf3d74486 100644 --- a/src/mono/nuget/mono-packages.proj +++ b/src/mono/nuget/mono-packages.proj @@ -17,6 +17,8 @@ + + diff --git a/src/mono/wasi/runtime/main.c b/src/mono/wasi/runtime/main.c index 10f87320e9a0b8..3a4c4ebf71fa71 100644 --- a/src/mono/wasi/runtime/main.c +++ b/src/mono/wasi/runtime/main.c @@ -113,6 +113,7 @@ int main(int argc, char * argv[]) { } ret = ret < 0 ? -ret : ret; + // until WASI can work with unix exit code https://github.com/WebAssembly/wasi-cli/pull/44 char* dotnet_wasi_print_exit_code = monoeg_g_getenv ("DOTNET_WASI_PRINT_EXIT_CODE"); if (ret != 0 && dotnet_wasi_print_exit_code && strcmp(dotnet_wasi_print_exit_code, "1") == 0) { diff --git a/src/mono/wasm/host/wasi/WasiEngineArguments.cs b/src/mono/wasm/host/wasi/WasiEngineArguments.cs index 64276047091847..a0d4de4a4ee5bf 100644 --- a/src/mono/wasm/host/wasi/WasiEngineArguments.cs +++ b/src/mono/wasm/host/wasi/WasiEngineArguments.cs @@ -30,6 +30,7 @@ public WasiEngineArguments(CommonConfiguration commonConfig) private OptionSet GetOptions() => new OptionSet { + // until WASI can work with unix exit code https://github.com/WebAssembly/wasi-cli/pull/44 { "forward-exit-code", "Forward process exit code via stderr", v => ForwardExitCode = true } }; diff --git a/src/tests/Common/CoreCLRTestLibrary/OutOfProcessTest.cs b/src/tests/Common/CoreCLRTestLibrary/OutOfProcessTest.cs index 66937878587ddd..2084bd02d96607 100644 --- a/src/tests/Common/CoreCLRTestLibrary/OutOfProcessTest.cs +++ b/src/tests/Common/CoreCLRTestLibrary/OutOfProcessTest.cs @@ -47,7 +47,7 @@ static OutOfProcessTest() && !OperatingSystem.IsTvOS() && !OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser() - && !OperatingSystem.IsOSPlatform("Wasi"); + && !OperatingSystem.IsWasi(); public static void RunOutOfProcessTest(string assemblyPath, string testPathPrefix) { diff --git a/src/tests/Common/XHarnessRunnerLibrary/RunnerEntryPoint.cs b/src/tests/Common/XHarnessRunnerLibrary/RunnerEntryPoint.cs index 1c229b18540dbd..03e8a6b35fcd6c 100644 --- a/src/tests/Common/XHarnessRunnerLibrary/RunnerEntryPoint.cs +++ b/src/tests/Common/XHarnessRunnerLibrary/RunnerEntryPoint.cs @@ -32,7 +32,7 @@ public static async Task RunTests( { entryPoint = new AppleEntryPoint(new SimpleDevice(assemblyName), runTestsCallback, assemblyName, filter, testExclusionTable); } - if (OperatingSystem.IsBrowser()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() ) { entryPoint = new WasmEntryPoint(runTestsCallback, assemblyName, filter, testExclusionTable); } @@ -45,7 +45,7 @@ public static async Task RunTests( entryPoint.TestsCompleted += (o, e) => anyFailedTests = e.FailedTests > 0; await entryPoint.RunAsync(); - if (OperatingSystem.IsBrowser()) + if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi() ) { // Browser expects all xharness processes to exit with 0, even in case of failure return 0; diff --git a/src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs b/src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs index c39a28e9c03f12..2f1237dc44403d 100644 --- a/src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs +++ b/src/tests/Common/XUnitWrapperGenerator/ITestInfo.cs @@ -248,6 +248,10 @@ private static string GetPlatformConditionFromTestPlatform(Xunit.TestPlatforms p { platformCheckConditions.Add("global::System.OperatingSystem.IsBrowser()"); } + if (platform.HasFlag(Xunit.TestPlatforms.Wasi)) + { + platformCheckConditions.Add("global::System.OperatingSystem.IsWasi()"); + } if (platform.HasFlag(Xunit.TestPlatforms.FreeBSD)) { platformCheckConditions.Add(@"global::System.OperatingSystem.IsFreeBSD()"); diff --git a/src/tests/tracing/eventpipe/common/IpcTraceTest.cs b/src/tests/tracing/eventpipe/common/IpcTraceTest.cs index 3f107c511d891d..ce058328d0e592 100644 --- a/src/tests/tracing/eventpipe/common/IpcTraceTest.cs +++ b/src/tests/tracing/eventpipe/common/IpcTraceTest.cs @@ -344,7 +344,7 @@ private int Validate(bool enableRundownProvider = true) // the process that created them, so we don't need to check on that platform. static public bool EnsureCleanEnvironment() { - if (!OperatingSystem.IsWindows() && !OperatingSystem.IsBrowser() && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS()) + if (!OperatingSystem.IsWindows() && !OperatingSystem.IsBrowser() && !OperatingSystem.IsWasi() && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS()) { Func<(IEnumerable>, List)> getPidsAndSockets = () => { From dd141e9480be778a5cc7d6cd3dfd87291edb70a9 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 2 Sep 2024 18:05:25 +0200 Subject: [PATCH 02/14] more --- src/libraries/System.Net.NameResolution/Directory.Build.props | 1 + .../System.Net.Primitives/src/System.Net.Primitives.csproj | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.NameResolution/Directory.Build.props b/src/libraries/System.Net.NameResolution/Directory.Build.props index 58979d42f06955..f58ea59921f19f 100644 --- a/src/libraries/System.Net.NameResolution/Directory.Build.props +++ b/src/libraries/System.Net.NameResolution/Directory.Build.props @@ -3,6 +3,7 @@ Microsoft true + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj index e71aaa8222e300..0c6feb6bd3db5a 100644 --- a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj +++ b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj @@ -138,7 +138,7 @@ Link="Common\Interop\Unix\System.Native\Interop.SocketAddress.cs" /> - + - + Date: Mon, 2 Sep 2024 18:24:16 +0200 Subject: [PATCH 03/14] fix --- ...cludeApiList.PNSE.Browser.txt => ExcludeApiList.PNSE.Wasm.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/libraries/System.Net.NameResolution/src/{ExcludeApiList.PNSE.Browser.txt => ExcludeApiList.PNSE.Wasm.txt} (100%) diff --git a/src/libraries/System.Net.NameResolution/src/ExcludeApiList.PNSE.Browser.txt b/src/libraries/System.Net.NameResolution/src/ExcludeApiList.PNSE.Wasm.txt similarity index 100% rename from src/libraries/System.Net.NameResolution/src/ExcludeApiList.PNSE.Browser.txt rename to src/libraries/System.Net.NameResolution/src/ExcludeApiList.PNSE.Wasm.txt From 88ed9f289990de5b3705fb86aa46e606cc62510f Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 3 Sep 2024 11:23:25 +0200 Subject: [PATCH 04/14] fix --- src/libraries/System.Net.Mail/Directory.Build.props | 2 ++ .../System.Net.Mail/src/System/Net/Mail/SmtpClient.Wasm.cs | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Mail/Directory.Build.props b/src/libraries/System.Net.Mail/Directory.Build.props index 43dc3a2640bbae..11cd8ade447b77 100644 --- a/src/libraries/System.Net.Mail/Directory.Build.props +++ b/src/libraries/System.Net.Mail/Directory.Build.props @@ -2,5 +2,7 @@ true + + wasi diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Wasm.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Wasm.cs index efed4be0ab56e2..b8b9c08b4cd65f 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Wasm.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.Wasm.cs @@ -28,7 +28,6 @@ public enum SmtpDeliveryFormat } [UnsupportedOSPlatform("browser")] - [UnsupportedOSPlatform("wasi")] public class SmtpClient : IDisposable { #pragma warning disable CS0067 // Field is not used From 3523771d948a51c9ffee0d2412f53ca478bd951e Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 3 Sep 2024 11:41:32 +0200 Subject: [PATCH 05/14] fix --- ...crosoft.Extensions.Configuration.FileExtensions.Tests.csproj | 2 -- .../Microsoft.Extensions.Configuration.UserSecrets.Tests.csproj | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/tests/Microsoft.Extensions.Configuration.FileExtensions.Tests.csproj b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/tests/Microsoft.Extensions.Configuration.FileExtensions.Tests.csproj index 1c170af7632837..9ae3029a16c23a 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/tests/Microsoft.Extensions.Configuration.FileExtensions.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/tests/Microsoft.Extensions.Configuration.FileExtensions.Tests.csproj @@ -3,8 +3,6 @@ $(NetCoreAppCurrent);$(NetFrameworkMinimum) true - - wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.csproj b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.csproj index d4b5282eea3458..0964f7795af269 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/tests/Microsoft.Extensions.Configuration.UserSecrets.Tests.csproj @@ -3,8 +3,6 @@ $(NetCoreAppCurrent);$(NetFrameworkMinimum) true - - wasi From acb91d2d9bf3902aff1b01fd22f26d92229efde6 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 3 Sep 2024 13:01:50 +0200 Subject: [PATCH 06/14] fix --- .../Directory.Build.props | 7 +++++++ .../Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props diff --git a/src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props new file mode 100644 index 00000000000000..a925a66bda08cd --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + wasi + + diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs index 66b356badc45d4..955375e3317933 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs @@ -17,7 +17,6 @@ namespace System.Net.Http public sealed class SocketsHttpHandler : HttpMessageHandler { [UnsupportedOSPlatformGuard("browser")] - [UnsupportedOSPlatformGuard("wasi")] public static bool IsSupported => false; public bool UseCookies From 446b4308301c764a396d157594befc27033aaead Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 3 Sep 2024 13:47:06 +0200 Subject: [PATCH 07/14] fix --- .../Directory.Build.props | 7 +++++++ ...icrosoft.Extensions.Configuration.FileExtensions.csproj | 2 -- .../Directory.Build.props | 7 +++++++ .../Directory.Build.props | 7 +++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props create mode 100644 src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props create mode 100644 src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props diff --git a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props new file mode 100644 index 00000000000000..a925a66bda08cd --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + wasi + + diff --git a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/src/Microsoft.Extensions.Configuration.FileExtensions.csproj b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/src/Microsoft.Extensions.Configuration.FileExtensions.csproj index 145cc29b27e20d..124b99b6338bc5 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/src/Microsoft.Extensions.Configuration.FileExtensions.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/src/Microsoft.Extensions.Configuration.FileExtensions.csproj @@ -5,8 +5,6 @@ true true Provides a base class for file-based configuration providers used with Microsoft.Extensions.Configuration and extension methods for configuring them. - - wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props new file mode 100644 index 00000000000000..a925a66bda08cd --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + wasi + + diff --git a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props new file mode 100644 index 00000000000000..a925a66bda08cd --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + wasi + + From a0ab217527ba5c5a098ab19bde7f661514d72bdf Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 3 Sep 2024 13:54:26 +0200 Subject: [PATCH 08/14] fix --- ...eApiList.PNSE.Wasm.txt => ExcludeApiList.PNSE.Browser.txt} | 0 .../src/System.Net.NameResolution.csproj | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/libraries/System.Net.NameResolution/src/{ExcludeApiList.PNSE.Wasm.txt => ExcludeApiList.PNSE.Browser.txt} (100%) diff --git a/src/libraries/System.Net.NameResolution/src/ExcludeApiList.PNSE.Wasm.txt b/src/libraries/System.Net.NameResolution/src/ExcludeApiList.PNSE.Browser.txt similarity index 100% rename from src/libraries/System.Net.NameResolution/src/ExcludeApiList.PNSE.Wasm.txt rename to src/libraries/System.Net.NameResolution/src/ExcludeApiList.PNSE.Browser.txt diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 41dccf89ade000..c5c8b4ffc9a582 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -10,7 +10,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.SystemNetNameResolution_PlatformNotSupported - ExcludeApiList.PNSE.Wasm.txt + ExcludeApiList.PNSE.Browser.txt @@ -96,7 +96,7 @@ Link="Common\Interop\Unix\System.Native\Interop.SocketAddress.cs" /> - + From 63ad2ecf427deb7765d4a8d05d05b79c4ffb6673 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 3 Sep 2024 14:09:26 +0200 Subject: [PATCH 09/14] feedback --- .../System.Net.Primitives/src/System.Net.Primitives.csproj | 2 +- src/mono/wasi/runtime/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj index 0c6feb6bd3db5a..3ebe3ed5dd79b9 100644 --- a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj +++ b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj @@ -155,7 +155,7 @@ Link="Common\Interop\Unix\System.Native\Interop.InterfaceNameToIndex.cs" /> - + Date: Tue, 3 Sep 2024 14:30:27 +0200 Subject: [PATCH 10/14] feedback --- .../System.Net.Primitives/src/System.Net.Primitives.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj index 3ebe3ed5dd79b9..e71aaa8222e300 100644 --- a/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj +++ b/src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj @@ -138,7 +138,7 @@ Link="Common\Interop\Unix\System.Native\Interop.SocketAddress.cs" /> - + Date: Tue, 3 Sep 2024 16:46:39 +0200 Subject: [PATCH 11/14] fix --- .../Directory.Build.props | 1 + .../Directory.Build.props | 1 + .../Directory.Build.props | 1 + .../Directory.Build.props | 1 + .../src/Microsoft.Extensions.Configuration.UserSecrets.csproj | 2 -- .../Microsoft.Extensions.Hosting.Systemd/Directory.Build.props | 1 + .../Microsoft.Extensions.Hosting/Directory.Build.props | 1 + 7 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props index a925a66bda08cd..e1c02fbef173e8 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props @@ -2,6 +2,7 @@ + false wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props index a925a66bda08cd..e1c02fbef173e8 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props @@ -2,6 +2,7 @@ + false wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props index a925a66bda08cd..e1c02fbef173e8 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props @@ -2,6 +2,7 @@ + false wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props index a925a66bda08cd..e1c02fbef173e8 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props @@ -2,6 +2,7 @@ + false wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/Microsoft.Extensions.Configuration.UserSecrets.csproj b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/Microsoft.Extensions.Configuration.UserSecrets.csproj index dd43b41bb8e32e..4b200df893380c 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/Microsoft.Extensions.Configuration.UserSecrets.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/Microsoft.Extensions.Configuration.UserSecrets.csproj @@ -5,8 +5,6 @@ true true User secrets configuration provider implementation for Microsoft.Extensions.Configuration. User secrets mechanism enables you to override application configuration settings with values stored in the local secrets file. You can use UserSecretsConfigurationExtensions.AddUserSecrets extension method on IConfigurationBuilder to add user secrets provider to the configuration builder. - - wasi diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props b/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props index 3a1d977d49dc3b..58970ec17ff3b0 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props @@ -4,6 +4,7 @@ hosting true + false wasi diff --git a/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props b/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props index d608edfe2846d6..3c72883cfa3a6c 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props @@ -3,6 +3,7 @@ true + false wasi From af0e2c2e3e5a49ac1ecaf44cff8c6c357afad2fa Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 3 Sep 2024 20:15:04 +0200 Subject: [PATCH 12/14] wip --- .../Directory.Build.props | 8 ----- .../Directory.Build.props | 8 ----- .../Directory.Build.props | 8 ----- .../Directory.Build.props | 8 ----- .../Directory.Build.props | 2 -- ...rosoft.Extensions.Configuration.Xml.csproj | 7 +++- .../src/XmlDocumentDecryptor.cs | 4 +++ .../Directory.Build.props | 2 -- ...t.Extensions.FileProviders.Physical.csproj | 7 +++- .../src/PhysicalFilesWatcher.cs | 32 +++++++++++++++++++ .../Directory.Build.props | 3 -- ...icrosoft.Extensions.Hosting.Systemd.csproj | 7 +++- .../src/SystemdNotifier.cs | 4 +++ .../Directory.Build.props | 3 -- .../System.Net.Mail/Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../System.Net.Sockets/Directory.Build.props | 2 +- 17 files changed, 61 insertions(+), 48 deletions(-) delete mode 100644 src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props delete mode 100644 src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props delete mode 100644 src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props delete mode 100644 src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props diff --git a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props deleted file mode 100644 index e1c02fbef173e8..00000000000000 --- a/src/libraries/Microsoft.Extensions.Configuration.FileExtensions/Directory.Build.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - false - wasi - - diff --git a/src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props deleted file mode 100644 index e1c02fbef173e8..00000000000000 --- a/src/libraries/Microsoft.Extensions.Configuration.Ini/Directory.Build.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - false - wasi - - diff --git a/src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props deleted file mode 100644 index e1c02fbef173e8..00000000000000 --- a/src/libraries/Microsoft.Extensions.Configuration.Json/Directory.Build.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - false - wasi - - diff --git a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props deleted file mode 100644 index e1c02fbef173e8..00000000000000 --- a/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/Directory.Build.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - false - wasi - - diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/Directory.Build.props b/src/libraries/Microsoft.Extensions.Configuration.Xml/Directory.Build.props index 9933943952b5ba..e2a84c6006dc87 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/Directory.Build.props @@ -2,7 +2,5 @@ true - - wasi diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj index c53df5f0c31473..94dc4600073f01 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj @@ -1,12 +1,17 @@ - $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + $(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) true true XML configuration provider implementation for Microsoft.Extensions.Configuration. This package enables you to read configuration parameters from XML files. You can use XmlConfigurationExtensions.AddXmlFile extension method on IConfigurationBuilder to add XML configuration provider to the configuration builder. + + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + $(DefineConstants);TARGET_WASI + + diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs index 51bfb352228a83..8382b62e4897d6 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs @@ -102,6 +102,9 @@ public XmlReader CreateDecryptingXmlReader(Stream input, XmlReaderSettings? sett [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] protected virtual XmlReader DecryptDocumentAndCreateXmlReader(XmlDocument document) { +#if TARGET_WASI + throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#else // Perform the actual decryption step, updating the XmlDocument in-place. EncryptedXml encryptedXml = _encryptedXmlFactory?.Invoke(document) ?? new EncryptedXml(document); encryptedXml.DecryptDocument(); @@ -110,6 +113,7 @@ protected virtual XmlReader DecryptDocumentAndCreateXmlReader(XmlDocument docume // Error messages based on this XmlReader won't show line numbers, // but that's fine since we transformed the document anyway. return document.CreateNavigator()!.ReadSubtree(); +#endif } } } diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/Directory.Build.props b/src/libraries/Microsoft.Extensions.FileProviders.Physical/Directory.Build.props index d608edfe2846d6..43dc3a2640bbae 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/Directory.Build.props @@ -2,7 +2,5 @@ true - - wasi diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Microsoft.Extensions.FileProviders.Physical.csproj b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Microsoft.Extensions.FileProviders.Physical.csproj index 030d46af2a6cc6..94793d17508524 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Microsoft.Extensions.FileProviders.Physical.csproj +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Microsoft.Extensions.FileProviders.Physical.csproj @@ -1,7 +1,7 @@ - $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + $(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) Microsoft.Extensions.FileProviders true $(NoWarn);CA1865;CA1866 @@ -10,6 +10,11 @@ File provider for physical files for Microsoft.Extensions.FileProviders. + + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + $(DefineConstants);TARGET_WASI + + diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs index d160cb8959d179..5bb49c18378ade 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs @@ -34,7 +34,11 @@ public class PhysicalFilesWatcher : IDisposable private readonly ConcurrentDictionary _wildcardTokenLookup = new(StringComparer.OrdinalIgnoreCase); private readonly FileSystemWatcher? _fileWatcher; +#if !TARGET_WASI // TODO remove with https://github.com/dotnet/runtime/pull/107185 private readonly object _fileWatcherLock = new(); +#else +#pragma warning disable CA1822 +#endif private readonly string _root; private readonly ExclusionFilters _filters; @@ -281,6 +285,9 @@ protected virtual void Dispose(bool disposing) [SupportedOSPlatform("maccatalyst")] private void OnRenamed(object sender, RenamedEventArgs e) { +#if TARGET_WASI + throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#else // For a file name change or a directory's name change notify registered tokens. OnFileSystemEntryChange(e.OldFullPath); OnFileSystemEntryChange(e.FullPath); @@ -309,6 +316,7 @@ ex is DirectoryNotFoundException || // Swallow the exception. } } +#endif } [UnsupportedOSPlatform("browser")] @@ -317,7 +325,11 @@ ex is DirectoryNotFoundException || [SupportedOSPlatform("maccatalyst")] private void OnChanged(object sender, FileSystemEventArgs e) { +#if TARGET_WASI + throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#else OnFileSystemEntryChange(e.FullPath); +#endif } [UnsupportedOSPlatform("browser")] @@ -326,11 +338,15 @@ private void OnChanged(object sender, FileSystemEventArgs e) [SupportedOSPlatform("maccatalyst")] private void OnError(object sender, ErrorEventArgs e) { +#if TARGET_WASI + throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#else // Notify all cache entries on error. foreach (string path in _filePathTokenLookup.Keys) { ReportChangeForMatchedEntries(path); } +#endif } [UnsupportedOSPlatform("browser")] @@ -339,6 +355,9 @@ private void OnError(object sender, ErrorEventArgs e) [SupportedOSPlatform("maccatalyst")] private void OnFileSystemEntryChange(string fullPath) { +#if TARGET_WASI + throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#else try { var fileSystemInfo = new FileInfo(fullPath); @@ -357,6 +376,7 @@ ex is SecurityException || { // Swallow the exception. } +#endif } [UnsupportedOSPlatform("browser")] @@ -365,6 +385,9 @@ ex is SecurityException || [SupportedOSPlatform("maccatalyst")] private void ReportChangeForMatchedEntries(string path) { +#if TARGET_WASI + throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#else if (string.IsNullOrEmpty(path)) { // System.IO.FileSystemWatcher may trigger events that are missing the file name, @@ -397,6 +420,7 @@ private void ReportChangeForMatchedEntries(string path) { TryDisableFileSystemWatcher(); } +#endif } [UnsupportedOSPlatform("browser")] @@ -405,6 +429,9 @@ private void ReportChangeForMatchedEntries(string path) [SupportedOSPlatform("maccatalyst")] private void TryDisableFileSystemWatcher() { +#if TARGET_WASI + throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#else if (_fileWatcher != null) { lock (_fileWatcherLock) @@ -418,6 +445,7 @@ private void TryDisableFileSystemWatcher() } } } +#endif } [UnsupportedOSPlatform("browser")] @@ -426,6 +454,9 @@ private void TryDisableFileSystemWatcher() [SupportedOSPlatform("maccatalyst")] private void TryEnableFileSystemWatcher() { +#if TARGET_WASI + throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#else if (_fileWatcher != null) { lock (_fileWatcherLock) @@ -438,6 +469,7 @@ private void TryEnableFileSystemWatcher() } } } +#endif } private static string NormalizePath(string filter) => filter.Replace('\\', '/'); diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props b/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props index 58970ec17ff3b0..1fa47343884033 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/Directory.Build.props @@ -3,8 +3,5 @@ hosting true - - false - wasi diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj index 94ee3bbf79c373..9b426cc55ad1b9 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj @@ -1,13 +1,18 @@ - $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.1 + $(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.1 true true true .NET hosting infrastructure for Systemd Services. + + $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) + $(DefineConstants);TARGET_WASI + + diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs index 2bc1865423f88e..8b8442063e7a7e 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs @@ -41,6 +41,9 @@ public void Notify(ServiceState state) return; } +#if TARGET_WASI + throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#else using (var socket = new Socket(AddressFamily.Unix, SocketType.Dgram, ProtocolType.Unspecified)) { var endPoint = new UnixDomainSocketEndPoint(_socketPath!); @@ -50,6 +53,7 @@ public void Notify(ServiceState state) // smaller than kernel buffers so we won't get blocked. socket.Send(state.GetData()); } +#endif } private static string? GetNotifySocketPath() diff --git a/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props b/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props index 3c72883cfa3a6c..43dc3a2640bbae 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props +++ b/src/libraries/Microsoft.Extensions.Hosting/Directory.Build.props @@ -2,8 +2,5 @@ true - - false - wasi diff --git a/src/libraries/System.Net.Mail/Directory.Build.props b/src/libraries/System.Net.Mail/Directory.Build.props index 11cd8ade447b77..129690e06bc247 100644 --- a/src/libraries/System.Net.Mail/Directory.Build.props +++ b/src/libraries/System.Net.Mail/Directory.Build.props @@ -2,7 +2,7 @@ true - + wasi diff --git a/src/libraries/System.Net.NameResolution/Directory.Build.props b/src/libraries/System.Net.NameResolution/Directory.Build.props index f58ea59921f19f..bc799605d32edf 100644 --- a/src/libraries/System.Net.NameResolution/Directory.Build.props +++ b/src/libraries/System.Net.NameResolution/Directory.Build.props @@ -3,7 +3,7 @@ Microsoft true - + browser;wasi \ No newline at end of file diff --git a/src/libraries/System.Net.Sockets/Directory.Build.props b/src/libraries/System.Net.Sockets/Directory.Build.props index f58ea59921f19f..bc799605d32edf 100644 --- a/src/libraries/System.Net.Sockets/Directory.Build.props +++ b/src/libraries/System.Net.Sockets/Directory.Build.props @@ -3,7 +3,7 @@ Microsoft true - + browser;wasi \ No newline at end of file From 7384b9734f4776aa1dc64fbd36f7b79676110405 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 3 Sep 2024 21:36:47 +0200 Subject: [PATCH 13/14] fix --- ...rosoft.Extensions.Configuration.Xml.csproj | 7 +--- .../src/XmlDocumentDecryptor.cs | 6 +-- ...t.Extensions.FileProviders.Physical.csproj | 7 +--- .../src/PhysicalFilesWatcher.cs | 39 ++++--------------- ...icrosoft.Extensions.Hosting.Systemd.csproj | 7 +--- .../src/SystemdNotifier.cs | 6 +-- 6 files changed, 14 insertions(+), 58 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj index 94dc4600073f01..c53df5f0c31473 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/Microsoft.Extensions.Configuration.Xml.csproj @@ -1,17 +1,12 @@ - $(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) true true XML configuration provider implementation for Microsoft.Extensions.Configuration. This package enables you to read configuration parameters from XML files. You can use XmlConfigurationExtensions.AddXmlFile extension method on IConfigurationBuilder to add XML configuration provider to the configuration builder. - - $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - $(DefineConstants);TARGET_WASI - - diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs index 8382b62e4897d6..c8bff167c5f046 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs @@ -102,9 +102,8 @@ public XmlReader CreateDecryptingXmlReader(Stream input, XmlReaderSettings? sett [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] protected virtual XmlReader DecryptDocumentAndCreateXmlReader(XmlDocument document) { -#if TARGET_WASI - throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 -#else + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 + // Perform the actual decryption step, updating the XmlDocument in-place. EncryptedXml encryptedXml = _encryptedXmlFactory?.Invoke(document) ?? new EncryptedXml(document); encryptedXml.DecryptDocument(); @@ -113,7 +112,6 @@ protected virtual XmlReader DecryptDocumentAndCreateXmlReader(XmlDocument docume // Error messages based on this XmlReader won't show line numbers, // but that's fine since we transformed the document anyway. return document.CreateNavigator()!.ReadSubtree(); -#endif } } } diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Microsoft.Extensions.FileProviders.Physical.csproj b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Microsoft.Extensions.FileProviders.Physical.csproj index 94793d17508524..030d46af2a6cc6 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Microsoft.Extensions.FileProviders.Physical.csproj +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Microsoft.Extensions.FileProviders.Physical.csproj @@ -1,7 +1,7 @@ - $(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) + $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) Microsoft.Extensions.FileProviders true $(NoWarn);CA1865;CA1866 @@ -10,11 +10,6 @@ File provider for physical files for Microsoft.Extensions.FileProviders. - - $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - $(DefineConstants);TARGET_WASI - - diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs index 5bb49c18378ade..aaf35606fd9877 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs @@ -34,11 +34,7 @@ public class PhysicalFilesWatcher : IDisposable private readonly ConcurrentDictionary _wildcardTokenLookup = new(StringComparer.OrdinalIgnoreCase); private readonly FileSystemWatcher? _fileWatcher; -#if !TARGET_WASI // TODO remove with https://github.com/dotnet/runtime/pull/107185 private readonly object _fileWatcherLock = new(); -#else -#pragma warning disable CA1822 -#endif private readonly string _root; private readonly ExclusionFilters _filters; @@ -280,14 +276,12 @@ protected virtual void Dispose(bool disposing) } [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] private void OnRenamed(object sender, RenamedEventArgs e) { -#if TARGET_WASI - throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 -#else // For a file name change or a directory's name change notify registered tokens. OnFileSystemEntryChange(e.OldFullPath); OnFileSystemEntryChange(e.FullPath); @@ -316,48 +310,39 @@ ex is DirectoryNotFoundException || // Swallow the exception. } } -#endif } [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] private void OnChanged(object sender, FileSystemEventArgs e) { -#if TARGET_WASI - throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 -#else OnFileSystemEntryChange(e.FullPath); -#endif } [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] private void OnError(object sender, ErrorEventArgs e) { -#if TARGET_WASI - throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 -#else // Notify all cache entries on error. foreach (string path in _filePathTokenLookup.Keys) { ReportChangeForMatchedEntries(path); } -#endif } [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] private void OnFileSystemEntryChange(string fullPath) { -#if TARGET_WASI - throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 -#else try { var fileSystemInfo = new FileInfo(fullPath); @@ -376,18 +361,15 @@ ex is SecurityException || { // Swallow the exception. } -#endif } [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] private void ReportChangeForMatchedEntries(string path) { -#if TARGET_WASI - throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 -#else if (string.IsNullOrEmpty(path)) { // System.IO.FileSystemWatcher may trigger events that are missing the file name, @@ -420,18 +402,15 @@ private void ReportChangeForMatchedEntries(string path) { TryDisableFileSystemWatcher(); } -#endif } [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] private void TryDisableFileSystemWatcher() { -#if TARGET_WASI - throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 -#else if (_fileWatcher != null) { lock (_fileWatcherLock) @@ -445,18 +424,15 @@ private void TryDisableFileSystemWatcher() } } } -#endif } [UnsupportedOSPlatform("browser")] + [UnsupportedOSPlatform("wasi")] [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] private void TryEnableFileSystemWatcher() { -#if TARGET_WASI - throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 -#else if (_fileWatcher != null) { lock (_fileWatcherLock) @@ -469,7 +445,6 @@ private void TryEnableFileSystemWatcher() } } } -#endif } private static string NormalizePath(string filter) => filter.Replace('\\', '/'); diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj index 9b426cc55ad1b9..94ee3bbf79c373 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/Microsoft.Extensions.Hosting.Systemd.csproj @@ -1,18 +1,13 @@ - $(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.1 + $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.1 true true true .NET hosting infrastructure for Systemd Services. - - $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - $(DefineConstants);TARGET_WASI - - diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs index 8b8442063e7a7e..562cef2519e022 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs @@ -41,9 +41,8 @@ public void Notify(ServiceState state) return; } -#if TARGET_WASI - throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 -#else + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 + using (var socket = new Socket(AddressFamily.Unix, SocketType.Dgram, ProtocolType.Unspecified)) { var endPoint = new UnixDomainSocketEndPoint(_socketPath!); @@ -53,7 +52,6 @@ public void Notify(ServiceState state) // smaller than kernel buffers so we won't get blocked. socket.Send(state.GetData()); } -#endif } private static string? GetNotifySocketPath() From 28ad3bd626fb01121e5758d7fa8c6a74f588b180 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Wed, 4 Sep 2024 08:14:25 +0200 Subject: [PATCH 14/14] fix --- .../src/XmlDocumentDecryptor.cs | 7 +++++-- .../src/SystemdNotifier.cs | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs index c8bff167c5f046..46b17fe1c9c9e8 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/src/XmlDocumentDecryptor.cs @@ -102,8 +102,11 @@ public XmlReader CreateDecryptingXmlReader(Stream input, XmlReaderSettings? sett [RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)] protected virtual XmlReader DecryptDocumentAndCreateXmlReader(XmlDocument document) { - if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 - +#if !NETSTANDARD2_1 && !NETSTANDARD2_0 && !NETFRAMEWORK // TODO remove with https://github.com/dotnet/runtime/pull/107185 + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); +#else + #pragma warning disable CA1416 +#endif // Perform the actual decryption step, updating the XmlDocument in-place. EncryptedXml encryptedXml = _encryptedXmlFactory?.Invoke(document) ?? new EncryptedXml(document); encryptedXml.DecryptDocument(); diff --git a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs index 562cef2519e022..a27a7c9154e675 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Systemd/src/SystemdNotifier.cs @@ -41,7 +41,11 @@ public void Notify(ServiceState state) return; } - if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185 +#if !NETSTANDARD2_1 && !NETSTANDARD2_0 && !NETFRAMEWORK // TODO remove with https://github.com/dotnet/runtime/pull/107185 + if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); +#else + #pragma warning disable CA1416 +#endif using (var socket = new Socket(AddressFamily.Unix, SocketType.Dgram, ProtocolType.Unspecified)) {