Double generic types and members with non-generic equivalents
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 38/100
Línea de trabajo
Comienza revisando la API genérica existente ParseResult.GetValue y los constructores de Option, tomando como alcance las sobrecargas basadas en Type propuestas. Compara el patrón con la API de DI no genérica y, después, verifica que las alternativas admitan el caso de uso de AOT sin reflexión mostrado, preservando al mismo tiempo el comportamiento genérico.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Examples
// In addition to these:
T? ParseResult.GetValue<T>(Option<T> option);
new Option<T>(string name, params string[] aliases);
// etc...
// Make it possible to call them like this:
object? ParseResult.GetValue(Option option, Type valueType);
new Option(Type valueType, string name, params string[] aliases);
This is somewhat similar to what we have in DI:
// We can add service like this:
services.AddSignleton<T>();
// Or this:
services.AddSingleton(Type serviceType);
Justification
I am making my own library that adds proper hosting API, making using System.CommandLine similar to any regular ASP.NET project.
For example:
Program.cs
app.MapCommand("foo", ([Option] FileInfo file) =>
{
foreach (string line in File.ReadLines(file.FullName))
Console.WriteLine(line);
});
ShellApplication.cs
public void MapCommand(string name, Delegate command)
{
RootCommand rootCommand = [];
ParameterInfo[] parameters = command.Method.GetParameters();
foreach (ParameterInfo parameterInfo in parameters)
{
if (parameterInfo.GetCustomAttribute<OptionAttribute>() is not null)
{
Option option = (typeof(Option<>).MakeGenericType(parameterInfo.ParameterType).GetConstructor([typeof(string), typeof(string[])])!.Invoke([name]) as Option)!;
rootCommand.Options.Add(option);
}
}
// etc...
}
At first glance this looks fine – just make a generic type using reflection. Only the problem is that this is not AOT compatible and will cause exceptions. Adding alternatives that accept types as parameters would solve this.
Additional context
I've glossed over the codebase, and it doesn't look like it will be that hard to implement changes. If that's ok with you, I can prepare a PR myself.
- Lenguaje dominante
- C#
- Estrellas
- 3.7k
- Forks
- 434
- Merge medio
- 4 h 46 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnet/command-line-api
-
German localization is incompletePosiblemente ocupada @b-v-d-e-v la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotnet/command-line-api#2852 ·
-
Incomplete French (fr) translation: RequiredOptionWasNotProvided not translatedPosiblemente ocupada @JPBlanc la tomó hace 105 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotnet/command-line-api#2822 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
dotnet/command-line-api#2792 · 2 comentarios · 16 reacciones ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
dotnet/command-line-api#2704 ·
-
GetCompletions should check exit code of invoked applicationPosiblemente ocupada @baradgur la tomó hace 1277 días. AbiertoArea-Completions bug help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dotnet/command-line-api#2137 · 1 comentario · 3 reacciones ·
Todos los issues de dotnet/command-line-api
Issues similares
-
[i18n] 安装实例完成后的成功提示未正确本地化Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
PCL-Community/PCL-CE#3658 ·
Los mantenedores suelen responder en 1 día
-
Deploy & Patch-issues opprettes ikke: create-pnd-issues.yml har feilet hver uke siden 2025-09-08Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Altinn/altinn-auth#4359 ·
Los mantenedores suelen responder en 1 día
-
アプリ: チャット 優先: 中 提案
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
yksr-melt/Meltype#243 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Workflows: a workflow stored with null conditions is skipped with an exception instead of runAbiertobug core
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
type/automation type/tech-debt
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día