Skip to content

Issue #3921 : preserve delegate construction - #4126

Open
marcusmalloc wants to merge 3 commits into
icsharpcode:masterfrom
marcusmalloc:master
Open

Issue #3921 : preserve delegate construction#4126
marcusmalloc wants to merge 3 commits into
icsharpcode:masterfrom
marcusmalloc:master

Conversation

@marcusmalloc

Copy link
Copy Markdown

Link to issue(s) this covers #3921

Problem

ILSpy decompiles and returns 'return M' and 'return new Action(M)' as 'return M.'

Solution

As @dgrunwald recommended, this PR adds an ILast instruction to distinguish cached / fresh delegates throughout decompilation.

  • At least one test covering the code changed

Please let me know if any changes need to be made to my implementation!

if (conversion.Conversion.Method.IsStatic
&& conversion.Conversion.Method is not LocalFunctionMethod { IsStaticLocalFunction: false }
&& conversion.Conversion.Method.Parameters.Count == type.GetDelegateInvokeMethod()?.Parameters.Count
&& expressionBuilder.settings.GetMinimumRequiredVersion() >= LanguageVersion.CSharp11_0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting way of using GetMinimumRequiredVersion... I'd prefer to have a separate setting, like with all the other features. Or maybe just omit it.

also patterns would fit nicely here: conversion.Conversion.Method is { IsStatic: true, ... } maybe?

@siegfriedpammer

Copy link
Copy Markdown
Member

Thank you for your contribution... what's the commit message [Decompiler] gpt-slop copy supposed to mean? To what degree did you use LLMs to implement this? Please give us some background info on your approach. Thanks!

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.

2 participants