I'm deploying my .NET7 application using Assembly Trimming and am working around the trimming issues.
There's this weird issue with the list of files of type ICollectionView<FileItem>
. The list items appear but only the text is missing, otherwise the app seems to work fine. Other listboxes are displaying fine.
public class FileItem
{
public FileItem() : this(string.Empty, string.Empty)
{ }
public FileItem(string name, string path)
{
Name = name;
Path = path;
}
public string Name { get; set; }
public string Path { get; set; }
}
Another issue is with serialization, I serialize to a settings file that contains this.
public List<SettingsPlaylistItem> Playlists { get; set; } = new();
It complains that SettingsPlaylistItem constructor is missing. Adding [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
does not help.
The only solution I found is to add this on app start. Is there a better solution?
// Solve trimming problems
var _ = new SettingsPlaylistItem();