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

Improve enums #1441

Closed
CreateAndInject opened this issue Mar 3, 2019 · 4 comments
Closed

Improve enums #1441

CreateAndInject opened this issue Mar 3, 2019 · 4 comments
Labels
C# Decompiler The decompiler engine itself Enhancement Areas for improvement

Comments

@CreateAndInject
Copy link
Contributor

CreateAndInject commented Mar 3, 2019

Original

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == (Keys.Control | Keys.R))
            {
                MessageBox.Show("OK");
            }
        }

ILSpy

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
	if (e.KeyData == (Keys)131154)
	{
		MessageBox.Show("OK");
	}
}
@dgrunwald
Copy link
Member

We already do this for enums marked as [Flags].
It's more difficult for something like Keys, because we don't want to decompose Keys.R into individual bits.

@CreateAndInject
Copy link
Contributor Author

There's no problem in Reflector.

@tamlin-mike
Copy link

@dgrunwald According to documentation the Keys enum is marked with [System.Flags].
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.keys

One could argue this is nuts, since ORing f.ex. S and T is nonsensical, but it is what it is.

@siegfriedpammer
Copy link
Member

The Flags-enum transformation does not work in this case because the individual members of the enumeration are overlapping.

@siegfriedpammer siegfriedpammer added C# Decompiler The decompiler engine itself Enhancement Areas for improvement labels Jul 14, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2020
ElektroKill pushed a commit to dnSpyEx/ILSpy that referenced this issue Aug 8, 2021
…alue with the highest Hamming Weight (popcount).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C# Decompiler The decompiler engine itself Enhancement Areas for improvement
Projects
None yet
Development

No branches or pull requests

4 participants