Skip to content

Lambda parameter 'params' and default values are dropped below C# 12 - #4337

Open
PreetRajput wants to merge 2 commits into
icsharpcode:masterfrom
PreetRajput:Preet/ILSpy-Issue4058
Open

PreetRajput wants to merge 2 commits into
icsharpcode:masterfrom
PreetRajput:Preet/ILSpy-Issue4058

Conversation

@PreetRajput

Copy link
Copy Markdown

#4058

Problem

Fixes the handling of optional and params parameters when decompiling lambda expressions, particularly when targeting C# language versions below C# 12.

Solution

  • For C# 12 and later, the decompiler emits optional parameter defaults and params modifiers directly in lambda parameter lists.
  • For earlier C# versions, it preserves optional parameter information using [Optional] and [DefaultParameterValue(value)] attributes instead of emitting unsupported default-value syntax.
  • Unsupported params modifiers are omitted for earlier language versions to ensure the generated code remains valid.

Tests

  • Ran the existing PrettyTestRunner.LambdaOptionalAndParamsParameters test.
  • Result: 4 passed, 0 failed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant