Skip to content

Trimmer warning for InsertAllAsync() #1291

@vividos

Description

@vividos

I'm trying to compile and publish my .NET MAUI app using Native AOT and trying to fix AOT warnings. Instead of calling

[RequiresUnreferencedCode("This method requires ''DynamicallyAccessedMemberTypes.All' on the runtime type of 'obj'.")]
public Task<int> UpdateAsync(object obj)

I'm calling

public Task<int> UpdateAsync(object obj, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objType)

and due to DynamicallyAccessedMembers the linker preserves by type I pass to the call. That works out OK and no trimmer warning is produced.

Now I try to do the same for InsertAllAsync():

[RequiresUnreferencedCode("This method requires ''DynamicallyAccessedMemberTypes.All' on the runtime type of all objects in 'objects'.")]
public Task<int> InsertAllAsync(IEnumerable objects, bool runInTransaction = true)

The replacement would be

[RequiresUnreferencedCode("This method requires ''DynamicallyAccessedMemberTypes.All' on the runtime type of all objects in 'objects'.")]
public Task<int> InsertAllAsync(IEnumerable objects, Type objType, bool runInTransaction = true)

Unfortunately, it is also marked with [RequiresUnreferencedCode]. I think the Type parameter should be marked with [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] instead, like in the UpdateAsync() method:

public Task<int> InsertAllAsync(IEnumerable objects, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objType, bool runInTransaction = true).

I checked the other methods taking a Type object and they all seem to be correct.

I can prepare a PR if that helps fixing the wrong attribute on InsertAllAsync().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions