Closed 0x53A closed 6 years ago
ad 1. This is likely because of the empty else branch, but might need further adjustments. ad 2. Likely the same problem as foreach currently depends on the UsingTransform ad 3. Yes ad 4. I don't see the point of this at all... is this dead code?
The Unit code is dead code.
Unit in F# is kind of like void in C# ... but it actually has a value.
That means there is no need for a differentiation between Action and Func. Action is just Func<Unit>
.
The compiler should normally erase unit to void, but in generic code, remnants of unit are sometimes left.
F# using is now properly decompiled again (see #900). The remaining problems need some adjustments to the loop detection. @dgrunwald would be nice if you could take over from here.
EDIT: changed the samples
The following F# code
compiles in release to this assembly ...
FscILSpyTest.exe.txt
which decompiles to this C#:
1) It would be dope if it decompiled a F#
use
to a C#using
. I added this transformation to the old decompiler engine: https://github.com/icsharpcode/ILSpy/pull/671 1) It would be cool if it emitted aforeach
for all of seq/list/array. 2) It would be nice if it dropped the emptyelse
blocks 3) the C# is invalid due to the variable naming:Unit _ = unit;
and_ = unit;
.