C# 14 allows lambdas converted to Expression<TDelegate> to contain
calls that rely on optional parameters and named arguments (previously
CS0853/CS0854; named arguments must still be in parameter position,
otherwise CS9307). The compiler fills in the defaults when emitting the
Expression factory calls, so the metadata contains ordinary trees with
all arguments explicit.
The green fixture pins that the decompiler already reconstructs such
trees as C# 14 optional-argument calls: trailing arguments equal to the
parameter default are dropped for static/instance/extension/interface/
generic methods, constructors and delegate invocations, including
decimal, enum, CancellationToken, NaN, DateTime and long defaults, and
defaults are kept explicit where dropping them would re-resolve to a
different overload. Named arguments are printed positionally. A
nullable default (int? n = 5) is not folded and stays explicit, which
is still valid output. Both RoslynLatest configs pass.
The indexer fixture is Assert.Ignore'd: any indexer accessor call whose
trailing argument equals the parameter's default value fails the
CallBuilder.ArgumentList.CheckNoNamedOrOptionalArguments Debug.Assert
(DecompilerException in debug builds); this reproduces with plain
non-tree indexer calls too. Both configs compile the fixture and fail
only at that assertion, not at fixture compilation.
Also observed (not covered by a fixture): the optional-argument
dropping inside expression trees is not gated on the C# 14 language
version, so decompiling to older language versions produces code that
fails CS0854 on recompilation.
Assisted-by: Claude:claude-fable-5:Claude Code