Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransformDisplayClassUsage not working. #1936

Closed
yyjdelete opened this issue Feb 25, 2020 · 0 comments
Closed

TransformDisplayClassUsage not working. #1936

yyjdelete opened this issue Feb 25, 2020 · 0 comments
Labels
Bug C# Decompiler The decompiler engine itself

Comments

@yyjdelete
Copy link
Contributor

yyjdelete commented Feb 25, 2020

Tested with 6.0.0.5559
And the last public working version is 5.0.2.5153. Maybe relate to 7c8458d#diff-1ae3ed7affb1f6f07c828648aa9889d5L283-L289 ?

Test Code

        public void Test1()
        {
            IEnumerable<object> outerCapture = null;
            for (int i = 0; i < 10; i++)
            {
                int innerCapture = 0;
                Action a = (delegate
                {
                    List<object> list = new List<object>();
                    ++innerCapture;
                    outerCapture = outerCapture == null ? list : outerCapture.Concat(list);
                });
                a.Invoke();
            }
        }

Output

Failed to convert the last assign in new versions.

public void Test1()
{
	IEnumerable<object> outerCapture = null;
	for (int i = 0; i < 10; i++)
	{
		int innerCapture = 0;
		((Action)delegate
		{
			List<object> list = new List<object>();
			int num = ++innerCapture;
+			<>c__DisplayClass2_0 <>c__DisplayClass2_;
+			<>c__DisplayClass2_0 <>c__DisplayClass2_2 = <>c__DisplayClass2_;
			IEnumerable<object> outerCapture2;
			if (outerCapture != null)
			{
				outerCapture2 = outerCapture.Concat(list);
			}
			else
			{
				IEnumerable<object> enumerable = list;
				outerCapture2 = enumerable;
			}
-			outerCapture = outerCapture2;
+			<>c__DisplayClass2_2.outerCapture = outerCapture2;
		})();
	}
}
@siegfriedpammer siegfriedpammer added Bug C# Decompiler The decompiler engine itself labels Feb 26, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2020
ElektroKill pushed a commit to dnSpyEx/ILSpy that referenced this issue Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug C# Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

2 participants