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

Use astbuilder for all integer literals #1322

Merged
merged 10 commits into from
Dec 10, 2018

Conversation

siegfriedpammer
Copy link
Member

No description provided.

@dgrunwald
Copy link
Member

This change still has some issues, a quick look at the roundtrip-diff showed:

  1. it broke the context-dependent hexadecimal output (why don't we have any tests for this?)
-		public bool IsFrozen => (flags & 0x200) != 0;
+		public bool IsFrozen => (flags & 512) != 0;
  1. it sometimes ends up introducing redundant casts, e.g. I've seen (byte)byte.MaxValue

@siegfriedpammer
Copy link
Member Author

No. 1 is fixed now.

No. 2 affects literals/constants of all small integer types, it seems:

fullName = ((version.MajorRevision != (short)5) ? Path.Combine(fullName, "2.0") : Path.Combine(fullName, "2.1"));

The left side is short and the right side should be implicitly convertible to short.

See https://github.com/icsharpcode/ILSpy/blob/use-astbuilder-for-all-integer-literals/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs#L2382:

The resolve result (5, System.Int16) is replaced by a different instance, but with the same values. Because of this, an explicit cast is added by ConvertTo.

@siegfriedpammer siegfriedpammer merged commit 4b9a74d into master Dec 10, 2018
@siegfriedpammer siegfriedpammer deleted the use-astbuilder-for-all-integer-literals branch December 13, 2018 09:01
ElektroKill pushed a commit to dnSpyEx/ILSpy that referenced this pull request Jul 12, 2021
…or-all-integer-literals

Use astbuilder for all integer literals
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