Skip to content

Reflection access from Pinvokes and InternalCalls should warn at callsite #2188

Description

@sbomer

Currently when the linker sees a PInvoke or InternalCall that is an instance method it preserves all fields of the declaring type: https://github.com/mono/linker/blob/762278c9c3e60f5a82733dc0386bd0cf7f0a2d22/src/linker/Linker.Steps/MarkStep.cs#L3266

This produces warnings if any of the fields is annotated. Would it make more sense to warn at the callsites to the interop method? Currently the origin is the interop method itself, which is unusual in cases where the required fields depend on the callsite - see dotnet/runtime#56593 (comment).

@MichalStrehovsky @LakshanF

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions