Skip to content

IMethodReferenceOperation for local function within static method should have a separate InstanceReferenceKind #51715

@christopherpaul

Description

@christopherpaul

Version Used:
Microsoft.CodeAnalysis.Analyzers 3.3.2
Microsoft.CodeAnalysis.CSharp.Workspaces 3.9.0

Steps to Reproduce:

  1. Use Roslyn to obtain an IOperation for the Test method in the following code block:
using System.Linq;
public class Subject
{
  public static int Test()
  {
    return Enumerable.Range(0, 3).Sum(LocalFunction);

    int LocalFunction(int x) 
    {
      return x + 1;
    } 
  }
}
  1. Drill down to find the IMethodReferenceOperation for the reference to LocalFunction.

Expected Behavior:
The IMethodReferenceOperation's Instance property is null, because the Test method is static.

Actual Behavior:
The Instance property is an IInstanceReferenceOperation of kind ContainingTypeInstance.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions