Skip to content

in is erroneously applied to parameter when parameter is this #3578

@nikitalita

Description

@nikitalita

If a templated function has a parameter is declared with in, and it is called with this as a parameter, ILSpy will erroneously apply in to it.

This only seems to happen on templated functions; if the function being called is a non-template, ILSpy will create a temporary variable set to this and use that as a parameter.

Input

public class TestClass
{
    
    public void DoThing<T>(in T x)
    {
        Console.WriteLine(x.ToString());
    }

    public void DoThingToSelf()
    {
        DoThing(this);
    }
    
}

Erroneous output

using System;

public class TestClass
{
	public void DoThing<T>(in T x)
	{
		Console.WriteLine(x.ToString());
	}

	public void DoThingToSelf()
	{
		DoThing(in this);
	}
}

Details

  • Product in use: IlSpyCmd
  • Version in use: current master

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions