Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not trimmer friendly in .NET 8 #538

Closed
espenrl opened this issue Dec 19, 2023 · 1 comment · Fixed by #551
Closed

Not trimmer friendly in .NET 8 #538

espenrl opened this issue Dec 19, 2023 · 1 comment · Fixed by #551

Comments

@espenrl
Copy link

espenrl commented Dec 19, 2023

Hi, I'm experiencing some issues with trimming on iOS and Android using toolkit 200.3.0.

ILLink : error IL2036: Esri.ArcGISRuntime.Toolkit.Maui.Primitives.AttachmentsPopupElementView.BuildDefaultItemTemplate(): Unresolved type 'Esri.ArcGISRuntime.Toolkit.Maui.Primitives.AttachmentViewModel' in 'DynamicDependencyAttribute'.
ILLink : error IL2037: Esri.ArcGISRuntime.Toolkit.Maui.OverviewMap..cctor(): No members were resolved for 'LoadStatus' on type 'Esri.ArcGISRuntime.Mapping.Map'. 

Temporary fix

<PropertyGroup>
    <NoWarn>$(NoWarn);IL2036;IL2037</NoWarn>
</PropertyGroup>

Investigation

[DynamicDependency(nameof(AttachmentViewModel.Thumbnail), "Esri.ArcGISRuntime.Toolkit.Maui.Primitives.AttachmentViewModel","Esri.ArcGISRuntime")]
[DynamicDependency(nameof(AttachmentViewModel.Name), "Esri.ArcGISRuntime.Toolkit.Maui.Primitives.AttachmentViewModel", "Esri.ArcGISRuntime")]
[DynamicDependency(nameof(AttachmentViewModel.Size), "Esri.ArcGISRuntime.Toolkit.Maui.Primitives.AttachmentViewModel", "Esri.ArcGISRuntime")]
[DynamicDependency(nameof(AttachmentViewModel.IsDownloadButtonVisible), "Esri.ArcGISRuntime.Toolkit.Maui.Primitives.AttachmentViewModel", "Esri.ArcGISRuntime")]
[DynamicDependency(nameof(AttachmentViewModel.IsDownloading), "Esri.ArcGISRuntime.Toolkit.Maui.Primitives.AttachmentViewModel", "Esri.ArcGISRuntime")]

AttachmentViewModel is a private class nested inside AttachmentsPopupElementView. I guess the full type name is incorrect.

private class AttachmentViewModel : System.ComponentModel.INotifyPropertyChanged
{
public AttachmentViewModel(PopupAttachment attachment)
{
Attachment = attachment;
Attachment.PropertyChanged += Attachment_PropertyChanged;

I haven't investigated the second error..

@dotMorten
Copy link
Member

dotMorten commented Jan 3, 2024

Good find! You're right the full type name is incorrect for AttachmentViewModel.
The other one I think it just need to change from Map.LoadStatus to GeoModel.LoadStatus

[DynamicDependency(nameof(Esri.ArcGISRuntime.Mapping.Map.LoadStatus), "Esri.ArcGISRuntime.Mapping.Map", "Esri.ArcGISRuntime")]

Having said that, trimming in .NET MAUI is still pretty limited and causing a lot of issues beyond the .NET SDKs's own libraries - even .NET MAUI has lots of issues and are still working through it. Generally I'd recommend turning trimming off for Esri.ArcGISRuntime since especially bindings are causing a lot of issues since MAUI can't properly analyze and preserve properties you're binding to. If you want to keep trimming on for our libraries, expect doing a lot of these DynamicDependency attributes for things you bind to but don't access directly in code-behind, and as this issue shows, it can be pretty error-prone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants