Skip to content

Decomilation compilation error: Call is Ambiguous between multiple methods due to named parameters #3626

@LazaroOnline

Description

@LazaroOnline

Summary

ILSpy decompiler sometimes adds named parameters to methods (as if it was a silver bullet),
but doing so can result in ambiguity compared to the same call without naming the parameters.

Input code

var obj = new A(true);

public class A
{
	public A(string start = "", bool enable = false) { }
	public A(bool enable, string? start = "") { }
}

Erroneous output

A a5 = new A(enable: true);

Compilation error:
The call is ambiguous between the following methods or properties: 'A.A(string, bool)' and 'A.A(bool, string?)'CS0121

Details

ILSpy version 9.1.0.7988+03b7444943e720b3134d296c0c8dd3876f8ea4ce
.NET version 8.0.22+a2266c728f63a494ccb6786d794da2df135030be
(current latest)

and same issue in the VS extension (icsharpcode.ilspy-vscode) v0.22.0 (current latest).

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