Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[WASI][draft] UnsupportedOSPlatformAttribute on the API surface #107185

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public static bool IsEntered(object obj)
private static partial bool Wait(ObjectHandleOnStack obj, int millisecondsTimeout);

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
public static bool Wait(object obj, int millisecondsTimeout)
{
ArgumentNullException.ThrowIfNull(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public static bool IsEntered(object obj)
#region Public Wait/Pulse methods

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
public static bool Wait(object obj, int millisecondsTimeout)
{
return GetCondition(obj).Wait(millisecondsTimeout, obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal static partial class Helpers
[UnsupportedOSPlatformGuard("browser")]
[UnsupportedOSPlatformGuard("wasi")]
public static bool IsRC2Supported => !OperatingSystem.IsAndroid() && !OperatingSystem.IsBrowser();
[UnsupportedOSPlatformGuard("wasi")]
#else
public static bool IsRC2Supported => true;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ protected XmlDocumentDecryptor() { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Microsoft.Extensions.Configuration.Xml can use EncryptedXml which may contain XSLTs in the xml. XSLTs require dynamic code.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Microsoft.Extensions.Configuration.Xml can use EncryptedXml. If you use encrypted XML files, your application might not have the algorithm implementations it needs. To avoid this problem, one option you can use is a DynamicDependency attribute to keep the algorithm implementations in your application.")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")]
protected virtual System.Xml.XmlReader DecryptDocumentAndCreateXmlReader(System.Xml.XmlDocument document) { throw null; }
}
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Microsoft.Extensions.Configuration.Xml can use EncryptedXml which may contain XSLTs in the xml. XSLTs require dynamic code.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,11 @@ public XmlReader CreateDecryptingXmlReader(Stream input, XmlReaderSettings? sett
/// <param name="document">The document.</param>
/// <returns>An XmlReader which can read the document.</returns>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[RequiresDynamicCode(RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
protected virtual XmlReader DecryptDocumentAndCreateXmlReader(XmlDocument document)
{
#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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static partial class SystemdHelpers
}
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
Expand All @@ -45,6 +46,7 @@ public void Dispose() { }
public System.Threading.Tasks.Task WaitForStartAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
}
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")]
public partial class SystemdNotifier : Microsoft.Extensions.Hosting.Systemd.ISystemdNotifier
{
public SystemdNotifier() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.Extensions.Hosting.Systemd
/// </summary>
[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("maccatalyst")]
[UnsupportedOSPlatform("tvos")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Microsoft.Extensions.Hosting.Systemd
/// Provides support to notify systemd about the service status.
/// </summary>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
public class SystemdNotifier : ISystemdNotifier
{
private const string NOTIFY_SOCKET = "NOTIFY_SOCKET";
Expand Down Expand Up @@ -41,12 +42,6 @@ public void Notify(ServiceState state)
return;
}

#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))
{
var endPoint = new UnixDomainSocketEndPoint(_socketPath!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,25 @@ public static partial class HostingHostBuilderExtensions
public static Microsoft.Extensions.Hosting.IHostBuilder ConfigureServices(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Action<Microsoft.Extensions.DependencyInjection.IServiceCollection> configureDelegate) { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public static System.Threading.Tasks.Task RunConsoleAsync(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Action<Microsoft.Extensions.Hosting.ConsoleLifetimeOptions> configureOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public static System.Threading.Tasks.Task RunConsoleAsync(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public static Microsoft.Extensions.Hosting.IHostBuilder UseConsoleLifetime(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder) { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("android")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")]
public static Microsoft.Extensions.Hosting.IHostBuilder UseConsoleLifetime(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder, System.Action<Microsoft.Extensions.Hosting.ConsoleLifetimeOptions> configureOptions) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ internal static ServiceProviderOptions CreateDefaultServiceProviderOptions(HostB
/// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public static IHostBuilder UseConsoleLifetime(this IHostBuilder hostBuilder)
Expand All @@ -356,6 +357,7 @@ public static IHostBuilder UseConsoleLifetime(this IHostBuilder hostBuilder)
/// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public static IHostBuilder UseConsoleLifetime(this IHostBuilder hostBuilder, Action<ConsoleLifetimeOptions> configureOptions)
Expand All @@ -375,6 +377,7 @@ public static IHostBuilder UseConsoleLifetime(this IHostBuilder hostBuilder, Act
/// <returns>A <see cref="Task"/> that only completes when the token is triggered or shutdown is triggered.</returns>
[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public static Task RunConsoleAsync(this IHostBuilder hostBuilder, CancellationToken cancellationToken = default)
Expand All @@ -391,6 +394,7 @@ public static Task RunConsoleAsync(this IHostBuilder hostBuilder, CancellationTo
/// <returns>A <see cref="Task"/> that only completes when the token is triggered or shutdown is triggered.</returns>
[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public static Task RunConsoleAsync(this IHostBuilder hostBuilder, Action<ConsoleLifetimeOptions> configureOptions, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Microsoft.Extensions.Hosting.Internal
/// </summary>
[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public partial class ConsoleLifetime : IHostLifetime, IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public static IHttpClientBuilder ConfigureHttpMessageHandlerBuilder(this IHttpCl
/// </para>
/// </remarks>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")] // We can support SocketsHttpHandler on top of wasi-socket, once we have it working https://github.com/dotnet/runtime/issues/98957
public static IHttpClientBuilder UseSocketsHttpHandler(this IHttpClientBuilder builder, Action<SocketsHttpHandler, IServiceProvider>? configureHandler = null)
{
ThrowHelper.ThrowIfNull(builder);
Expand Down Expand Up @@ -320,6 +321,7 @@ public static IHttpClientBuilder UseSocketsHttpHandler(this IHttpClientBuilder b
/// </para>
/// </remarks>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
public static IHttpClientBuilder UseSocketsHttpHandler(this IHttpClientBuilder builder, Action<ISocketsHttpHandlerBuilder> configureBuilder)
{
ThrowHelper.ThrowIfNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static class SocketsHttpHandlerBuilderExtensions
/// <param name="configure">A delegate that is used to modify a <see cref="SocketsHttpHandler"/>.</param>
/// <returns>An <see cref="ISocketsHttpHandlerBuilder"/> that can be used to configure the handler.</returns>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")] // We can support SocketsHttpHandler on top of wasi-socket, once we have it working https://github.com/dotnet/runtime/issues/98957
public static ISocketsHttpHandlerBuilder Configure(this ISocketsHttpHandlerBuilder builder, Action<SocketsHttpHandler, IServiceProvider> configure)
{
builder.Services.Configure<HttpClientFactoryOptions>(builder.Name, options =>
Expand Down Expand Up @@ -59,13 +60,15 @@ public static ISocketsHttpHandlerBuilder Configure(this ISocketsHttpHandlerBuild
/// </para>
/// </remarks>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
public static ISocketsHttpHandlerBuilder Configure(this ISocketsHttpHandlerBuilder builder, IConfiguration configuration)
{
SocketsHttpHandlerConfiguration parsedConfig = ParseSocketsHttpHandlerConfiguration(configuration);
return Configure(builder, (handler, _) => FillFromConfig(handler, parsedConfig));
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
private static void FillFromConfig(SocketsHttpHandler handler, in SocketsHttpHandlerConfiguration config)
{
if (config.PooledConnectionIdleTimeout is not null)
Expand Down Expand Up @@ -188,6 +191,7 @@ private readonly record struct SocketsHttpHandlerConfiguration
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
private static SocketsHttpHandlerConfiguration ParseSocketsHttpHandlerConfiguration(IConfiguration config)
{
return new SocketsHttpHandlerConfiguration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Microsoft.Extensions.Logging
{
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")]
public static partial class ConsoleLoggerExtensions
{
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down Expand Up @@ -107,6 +108,7 @@ public ConsoleLoggerOptions() { }
}
[Microsoft.Extensions.Logging.ProviderAliasAttribute("Console")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("wasi")]
public partial class ConsoleLoggerProvider : Microsoft.Extensions.Logging.ILoggerProvider, Microsoft.Extensions.Logging.ISupportExternalScope, System.IDisposable
{
public ConsoleLoggerProvider(Microsoft.Extensions.Options.IOptionsMonitor<Microsoft.Extensions.Logging.Console.ConsoleLoggerOptions> options) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Microsoft.Extensions.Logging.Console
{
[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
internal sealed class AnsiParsingLogConsole : IConsole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal sealed class ConsoleFormatterConfigureOptions : IConfigureOptions<Conso
private readonly IConfiguration _configuration;

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
public ConsoleFormatterConfigureOptions(ILoggerProviderConfiguration<ConsoleLoggerProvider> providerConfiguration)
{
_configuration = providerConfiguration.GetFormatterOptionsSection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.Extensions.Logging.Console
/// A logger that writes messages in the console.
/// </summary>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
internal sealed class ConsoleLogger : ILogger, IBufferedLogger
{
private readonly string _name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal sealed class ConsoleLoggerConfigureOptions : IConfigureOptions<ConsoleL
private readonly IConfiguration _configuration;

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
public ConsoleLoggerConfigureOptions(ILoggerProviderConfiguration<ConsoleLoggerProvider> providerConfiguration)
{
_configuration = providerConfiguration.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Microsoft.Extensions.Logging
/// Provides extension methods for the <see cref="ILoggingBuilder"/> and <see cref="ILoggerProviderConfiguration{ConsoleLoggerProvider}"/> classes.
/// </summary>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
public static partial class ConsoleLoggerExtensions
{
internal const string RequiresDynamicCodeMessage = "Binding TOptions to configuration values may require generating dynamic code at runtime.";
Expand Down Expand Up @@ -175,6 +176,7 @@ internal static IConfiguration GetFormatterOptionsSection(this ILoggerProviderCo
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
internal sealed class ConsoleLoggerFormatterConfigureOptions<TFormatter, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TOptions> : ConfigureFromConfigurationOptions<TOptions>
where TOptions : ConsoleFormatterOptions
where TFormatter : ConsoleFormatter
Expand All @@ -188,6 +190,7 @@ public ConsoleLoggerFormatterConfigureOptions(ILoggerProviderConfiguration<Conso
}

[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
internal sealed class ConsoleLoggerFormatterOptionsChangeTokenSource<TFormatter, TOptions> : ConfigurationChangeTokenSource<TOptions>
where TOptions : ConsoleFormatterOptions
where TFormatter : ConsoleFormatter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Microsoft.Extensions.Logging.Console
{
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
internal class ConsoleLoggerProcessor : IDisposable
{
private readonly Queue<LogMessageEntry> _messageQueue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Microsoft.Extensions.Logging.Console
/// A provider of <see cref="ConsoleLogger"/> instances.
/// </summary>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[ProviderAlias("Console")]
public partial class ConsoleLoggerProvider : ILoggerProvider, ISupportExternalScope
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace System.Collections.Concurrent
{
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("wasi")]
public partial class BlockingCollection<T> : System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.ICollection, System.Collections.IEnumerable, System.IDisposable
{
public BlockingCollection() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace System.Collections.Concurrent
/// </remarks>
/// <typeparam name="T">Specifies the type of elements in the collection.</typeparam>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[DebuggerTypeProxy(typeof(BlockingCollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}, Type = {_collection}")]
public class BlockingCollection<T> : IEnumerable<T>, ICollection, IDisposable, IReadOnlyCollection<T>
Expand Down Expand Up @@ -1743,6 +1744,7 @@ public BlockingCollectionDebugView(BlockingCollection<T> collection)

/// <summary>Returns a snapshot of the underlying collection's elements.</summary>
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("wasi")]
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public T[] Items
{
Expand Down
Loading
Loading