-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
ToCsharpCode: format block inside expression in { ... }
#354
base: master
Are you sure you want to change the base?
Conversation
57ff039
to
e1f27ce
Compare
Sorry, I forgot that I also changed handling of |
e1f27ce
to
59fc220
Compare
Thanks for PR. I will check later. |
There are too many uncertainties with those changes. Regarding Regarding the proper expression block formatting. I want either a compile-able code or Let's keep this PR open and see what we can improve. |
…crementAssign to nullable member now works
It's not valid C# code, but neither was it valid before this change. This makes the code eaiser to read (IMHO), since the block scope is clearly visible.
59fc220
to
3369c2b
Compare
Sorry, I forgot about this for some time... I have removed the unrelated change, will make a separate PR for it. It will now print comments about the invalid syntax. In general, I could not come up with a way to output valid C#, but we can add some heuristics for the special cases when it's possible.
|
78193fa
to
47fbdf4
Compare
47fbdf4
to
f0ca1d8
Compare
When a block is inside another expression (binary, unary, assignment) it is now formatted into braces. It's not valid C# code, but neither was it valid before this change. This makes the code eaiser to read (IMHO), since the block scope is clearly visible.
My example expression, before the change:
After the change:
If you have any other ideas how to format such code, I'd be happy to incomporate them. I was considering these alternatives:
{ ... }
, rewrite it as(Func<ResultType>() => { })()
, since that would compile.unary(block(a, b, c, d))
->block(a, b, c, unary(d))
.binary(Method1(), Block(Method2()))
, I'd either have to reorder the method calls (incorrect), or add temporary variables (complex and noisy)