commandlineparser / commandlineparser/commandline

IL2104: Assembly 'CommandLine' produced trim warnings

オープン
#808 コメント 0 件 リアクション 7 件 担当者 0 名 GitHub で見る
主要言語
C#
スター
4.8k
フォーク
478
PR マージ指標
30日以内にマージされた PR はありません

説明

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);
}
}
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。