commandlineparser / commandlineparser/commandline
IL2104: Assembly 'CommandLine' produced trim warnings
- Lingua principale
- C#
- Stelle
- 4.8k
- Fork
- 478
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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);
}
}
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Partire da CommandLine.Core.TypeConverter.ConvertString e ispezionare la chiamata a TypeDescriptor.GetConverter mostrata nel report. Riprodurre l’avviso di Application Trimming, quindi determinare se il percorso di conversione è compatibile con il trimming e verificare che l’avviso venga risolto senza interrompere la conversione da string a TimeSpan.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100