Fix #3180: Spell out type arguments of a null-conditional extension call

When the extension method call cannot be written without type arguments
(another extension method with the same name and a different arity is
found first), the call falls back to the static form. For 'a?.M()' that
fallback produced 'Enumerable.Count(s?)', which is not valid C#. Writing
the type arguments excludes the extension methods of a different arity,
so for a null-conditional target the type arguments are tried before
giving up.
This commit is contained in:
dualfroz committed 2026-10-03 11:46:13 +02:00
1 parent a6526a1dab
commit 8c8b8caad8
3 files changed
+52 -5

No files matched your search

@@ -932,6 +932,12 @@ namespace ICSharpCode.Decompiler.Tests
await RunForLibrary(cscOptions: cscOptions);
}
[Test]
public async Task Issue3180([ValueSource(nameof(roslynOnlyOptions))] CompilerOptions cscOptions)
{
await RunForLibrary(cscOptions: cscOptions);
}
[Test]
public async Task AssemblyCustomAttributes([ValueSource(nameof(defaultOptions))] CompilerOptions cscOptions)
{