-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Parenthesize interpolations containing global::
#3463
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
Parenthesize interpolations containing global::
#3463
Conversation
|
Ad recursion: You can avoid stack overflows by using ILSpy/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs Lines 291 to 337 in 03b7444
|
|
Note to self: do not review pull requests when not entirely awake :( sorry, I gave wrong feedback. We cannot prevent stack overflows in this case, because the whole thing is using the Visitor pattern. So the problem remains and the performance might even be worse due to the use of LINQ. So, is there actually anything we could do to limit the number of nodes to check? Can we, for example, stop at anonymous functions/lambdas? Do we still need to disambiguate inside invocation argument lists? Might we be able to just look at the top-level expression? This is fine according to SharpLab... So I guess, we can stop descending as soon as we find:
What do you think? |
|
I implemented what you suggested. However, I encountered another issue that's preventing my tests from passing. |
* Cleaner output * More unit testing * More efficient tree search
53f0032 to
5145b3b
Compare
|
While fixing #3464 I noticed that |
ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertParenthesesVisitor.cs
Outdated
Show resolved
Hide resolved
ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertParenthesesVisitor.cs
Outdated
Show resolved
Hide resolved
ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertParenthesesVisitor.cs
Outdated
Show resolved
Hide resolved
* Update Lambda1 to be invariant * Visit descendents before deciding whether or not to parenthesize an interpolation expression * Rename local function * Remove branch for conditional expressions * Handle Lambda expressions without a block body * Check for parenthesized expressions
This is a recent change caused by you fixing #3464. Previously, the decompiler would emit the cast always. I added a pragma directive in the unit test to choose the appropriate format based on framework and C# version. |
ICSharpCode.Decompiler.Tests/TestCases/Pretty/GloballyQualifiedTypeInStringInterpolation.cs
Outdated
Show resolved
Hide resolved
|
Also, I notice that you seem to normal merge all pull requests, even though mine almost always have a few "junk" commits. Is there a reason you don't squash merge? |
Yes, my comment was imprecise: While playing around with your test case (in order to decide whether I can pass
I usually organize my commits into smaller self-contained units/changes to make bisecting after bug reports easier. If a PR has somewhat organized commits I usually just do a normal merge, however, if there is junk in there, I do squash-merges too. It all the depends on the person creating the PR. |
|
Is there something else I need to do for this pull request to be merged? |
ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertParenthesesVisitor.cs
Outdated
Show resolved
Hide resolved
No, I just wasn't sure whether you are done yet. |
|
Thank you very much for your continued contributions! |
|
No problem. I appreciate your reviews. |
Resolves #3447
Solution
InsertParenthesesVisitorclass.global::. Is there a better (more performant) way to check?