`Command` class violates design rule CA1010
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Comienza en la declaración enlazada de src/System.CommandLine/Command.cs y reproduce CA1010 con AnalysisMode establecido en Recommended o All usando el ejemplo MyCommand. Se considera terminado cuando los comandos que heredan públicamente ya no emiten CA1010, manteniendo al mismo tiempo el comportamiento existente de los elementos secundarios de Command.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
The System.CommandLine.Command class implements non-generic IEnumerable, but it does not implement IEnumerable<T>.
This causes classes inheriting from the Command class to violate design rule CA1010.
For projects with AnalysisMode set to Recommended or All, warning CA1010 will occur.
Build succeeded.
/home/smdn/temp/cli/Lib.cs(5,14): warning CA1010: Type 'MyCommand' directly or indirectly inherits 'IEnumerable' without implementing 'IEnumerable<T>'. Publicly-visible types should implement the generic version to broaden usability. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1010) [/home/smdn/temp/cli/cli.csproj]
1 Warning(s)
0 Error(s)
This simply triggers a warning and does not corrupt any functionality of System.CommandLine.
However, since the cause of the warning is not easy to find out and it may cause confusion, so I think this should be fixed.
Steps to reproduce
Set AnalysisMode to Recommended or All in the csproj file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- Enable design rules including CA1010 -->
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.1" />
</ItemGroup>
</Project>
Create a class that inherits from the Command class.
using System.CommandLine;
namespace MyLibrary;
// warning CA1010: Type 'MyCommand' directly or indirectly inherits 'IEnumerable' without implementing 'IEnumerable<T>'. Publicly-visible types should implement the generic version to broaden usability. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1010)
public class MyCommand(string name, string? description) : Command(name, description) { }
Workarounds
The following workarounds are available to avoid this warning.
Workaround 1: disable warning CA1010
#pragma warning disable CA1010
public class MyCommand(string name, string? description) : Command(name, description)
{
}
#pragma warning restore CA1010
Workaround 2: implement IEnumerator<Symbol>
public class MyCommand(string name, string? description) : Command(name, description)
{
// Implement IEnumerator<Symbol> in order to suppress warning CA1010.
public IEnumerator<Symbol> GetEnumerator() => Children.GetEnumerator();
}
Workaround 3: reduce AnalysisMode
<!-- Reduce `AnalysisMode` to either `None`, `Default`, or `Minimum`. -->
<AnalysisMode>Minimum</AnalysisMode>
- Lenguaje dominante
- C#
- Estrellas
- 3.7k
- Forks
- 434
- Merge medio
- 6 h 27 min
- PR fusionados (30 d)
- 2
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 19 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotnet/command-line-api#2852 ·
Los mantenedores suelen responder en 1 día
-
Incomplete French (fr) translation: RequiredOptionWasNotProvided not translatedPosiblemente ocupada @JPBlanc la tomó hace 117 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotnet/command-line-api#2822 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
dotnet/command-line-api#2792 · 2 comentarios · 16 reacciones ·
Los mantenedores suelen responder en 1 día
-
`Argument.Arity` modify internal state on first get access.Posiblemente ocupada @zjdangge la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
dotnet/command-line-api#2704 ·
Los mantenedores suelen responder en 1 día
-
GetCompletions should check exit code of invoked applicationPosiblemente ocupada @baradgur la tomó hace 1288 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 ·
Los mantenedores suelen responder en 1 día
Todos los issues de dotnet/command-line-api
Issues similares
-
The test-platform skill doesn't say what three of its failures look likePosiblemente ocupada @yasmoradi la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
bitfoundation/bitplatform#14022 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
getsentry/sentry-dotnet#5756 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area-TableView bug needs-triage team-Controls
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
microsoft/microsoft-ui-xaml#12351 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
AudioClient and ImageClient file path overloads send the full local path as the multipart file namePosiblemente ocupada @sebxt la tomó hoy. Abiertoarea: audio area: images feature-request
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
openai/openai-dotnet#1453 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 1 día