ILLink analyzer doesn't see operator method annotations

Open
#119,110 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp

Research direction

Start by reproducing the provided C# operator-method example in the ILLink Roslyn analyzer. Trace how annotated operator parameters and return values are analyzed, then verify that the mismatch reports IL2072 rather than IL2062 for the return case and handles annotated parameters similarly.

Written by the indexing model from the issue text.

Description

area-Tools-ILLink

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).

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.