Skip to content

Warning origins for warnings originating from event accessors are very confusing #100499

@vitek-karas

Description

@vitek-karas

Currently MarkEvent will directly call MarkMethod(add_event) and MarkMethod(remove_Event) with the origin set to the event itself. So for example:

// IL2026 - about the add_event
public event EventHandler TestEvent {
    [RequiresUnreferencedCode()]
    add {}
}

The warning is reported on the event itself and not on the callsite actually accessing the event. It's also reported repeatedly (if there are multiple callsites).

This gets potentially even worse because ProcessEvent(add_event) will call MarkEvent(event) and so that will potentially trigger the warning multiple times on its own.

RUC on type makes this even worse since both accessors are automatically RUC and this loops on itself (I think I saw the warning triplicated and on the wrong place).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Tools-ILLink.NET linker development as well as trimming analyzers

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions