commandlineparser / commandlineparser/commandline
IL2104: Assembly 'CommandLine' produced trim warnings
- Lenguaje dominante
- C#
- Estrellas
- 4.8k
- Forks
- 478
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I'm getting an error message indicating the library is using a method that is incompatible with [application trimming](https://aka.ms/dotnet-illink/libraries).
From what I can see, the specific issue is with the `System.ComponentModel.TypeDescriptor.GetConverter` method. Generic `TypeConverters` may require the generic types to be annotated. An option would be to use `GetConverterTrimUnsafe` if we can be sure the converter is trim compatible (type is not `Nullable`).
```cs
// CommandLine.Core.TypeConverter.ConvertString
private static object ConvertString(string value, Type type, CultureInfo conversionCulture)
{
try
{
return Convert.ChangeType(value, type, conversionCulture);
}
catch (InvalidCastException)
{
// Required for converting from string to TimeSpan because Convert.ChangeType can't
return System.ComponentModel.TypeDescriptor.GetConverter(type).ConvertFrom(null, conversionCulture, value);
}
}
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comience en CommandLine.Core.TypeConverter.ConvertString e inspeccione la llamada a TypeDescriptor.GetConverter que se muestra en el informe. Reproduzca la advertencia de Application Trimming y, a continuación, determine si la ruta de conversión es compatible con el trimming y verifique que la advertencia se resuelve sin romper la conversión de string a TimeSpan.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp
- Área
- cli
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100