Skip to content

Wrong Collection initializer #3091

@Solaestas

Description

@Solaestas

Input code

public class Test
{
	public static Test Create()
	{
		var ins = new Test();
		ins.Add(2);
		ins.Add(2);
		return ins;
	}
}

public static class TestExtension
{
	public static void Add(this Test obj, int value) { }
}

Erroneous output

public class Test
{
	public static Test Create()
	{
		return new Test { 2, 2 };
	}
}

public static class TestExtension
{
	public static void Add(this Test obj, int value)
	{
	}
}

Language version is C# 10.0 / VS2022
Collection initializer requires its type 'type' to implement System.Collections.IEnumerable.

Details

  • Product in use: VS extension
  • Version in use: 8.1.1.7464

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDecompilerThe decompiler engine itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions