Skip to content

ILLink analyzer doesn't see operator method annotations #119110

Open

Description

@sbomer

The ILLink Roslyn analyzer doesn't properly handle operator methods. It doesn't see annotated operator method parameters, and instead treats operator method returns as unknown values:

Repro:

var result = new OperatorType() - new OperatorType();
result.RequiresPublicMethods(); // Should report IL2072 about mismatch. Instead reports IL2062 (unknown value passed to RequiresPublicMethods).

private sealed class OperatorType : TestSystemTypeBase
{
    [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)]
    public static Type operator -(OperatorType left, OperatorType right) => ...
}

Annotated operator parameters are similar. This is a very niche scenario since it requires defining operators for annotatable types (System.Type for example).

Activity

  1. added
    area-Tools-ILLink
    on Aug 26, 2025
  2. added
    untriaged
    on Aug 26, 2025
  3. added this to the Future milestone on Aug 26, 2025
  4. dotnet-policy-service commented on Aug 26, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/illink
    See info in area-owners.md if you want to be subscribed.

  5. removed
    untriaged
    on Aug 26, 2025
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

    area-Tools-ILLink

    Type

    No type

    Projects

    • Status
      No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions