Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[wasi] TaskToAsyncResult.Begin throws PlatformNotSupportedException

Abierto Apto para principiantes
#134,955 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
csharp

Línea de trabajo

Comienza en src/libraries/Common/src/System/Threading/Tasks/TaskToAsyncResult.cs e inspecciona la comprobación de WASI en Begin. Ejecuta las pruebas de TaskToAsyncResultTests, incluida InvalidArguments_ThrowExceptions, para confirmar que el wrapper de APM funciona en plataformas de un solo hilo. La tarea estará terminada cuando Begin ya no falle incondicionalmente en WASI y el comportamiento bloqueante de AsyncWaitHandle siga tratándose adecuadamente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

arch-wasm area-System.Threading.Tasks os-wasi
Description

System.Threading.Tasks.TaskToAsyncResult.Begin unconditionally throws PlatformNotSupportedException on WASI:

// src/libraries/Common/src/System/Threading/Tasks/TaskToAsyncResult.cs
public static IAsyncResult Begin(Task task, AsyncCallback? callback, object? state)
{
#if NET
    if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185

The TODO points at https://github.com/dotnet/runtime/pull/107185, a draft that added UnsupportedOSPlatform annotations for WASI; it was closed without merging. So the check remains and nothing tracks it.

Begin wraps a Task in an IAsyncResult and schedules the callback as a continuation. That does not need extra threads, although code that blocks on the returned AsyncWaitHandle would.

The APM helpers throughout the libraries go through it, so on WASI every Begin*/End* pattern built on TaskToAsyncResult fails, as does Task.Factory.FromAsync over such a pair. In the CoreCLR WASI library test runs on https://github.com/dotnet/runtime/pull/134813, all six TaskToAsyncResultTests tests that run on a single-threaded platform fail this way. That includes InvalidArguments_ThrowExceptions, which expects ArgumentNullException.

Proposed fix

Remove the WASI check so Begin works as on browser. If blocking on AsyncWaitHandle must stay unsupported, keep that limitation where the wait happens. Otherwise, annotate the API as unsupported on WASI instead of throwing unconditionally.

[!NOTE]
This issue was drafted with the help of GitHub Copilot.

Lenguaje dominante
C#
Estrellas
18.4k
Forks
5.7k
Merge medio
2 d 20 h
PR fusionados (30 d)
652

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dotnet/runtime

Todos los issues de dotnet/runtime

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.