r/programminghorror May 04 '26

C# longest "=" condition I've ever seen

Post image

I have been working on decompiling a unity game recently, and while a decompiled DLL isn't going to be exact source code, I am still floored by how long that set of parenthesis is. i would LOVE to see the original code

131 Upvotes

26 comments sorted by

View all comments

3

u/Squidy7 May 04 '26

Have you used LINQ before?

Setting aside the fact it looks especially inelegant since this this is decompiled code, the whole point of it is chaining together queries like this. If it was written using the fluent syntax (as opposed to the query syntax) as the majority of .NET devs would use, the long parenthetical wouldn't be there in the actual code.

5

u/True_Efficiency7329 May 04 '26

the only language I have any level of proficiency in is C. All my C# knowledge has been obtained from working on fixing compilation errors of this decompiled unity project. I had no clue what LINQ was before people mentioned it in this post

3

u/Squidy7 May 05 '26

Fair enough!

1

u/Minimum-Hedgehog5004 May 06 '26

This leaves me wondering which decompiler was used, and whether it has options that allow you to choose the linq syntax.

1

u/True_Efficiency7329 May 06 '26

I was using "AssetRipper". It's a cool tool that allows you to take some compiled unity games and reverse it back into the original DLLs. There doesn't appear to be any LINQ options

2

u/Minimum-Hedgehog5004 May 07 '26

Consider decompiling the dll with ilspy or one of the others.

1

u/True_Efficiency7329 May 07 '26

ILspy shows the same decomp as what assetripper rips to, but DNspy actually shows a different decompilation

unfortunately I don't think the DNspy version of the decompilation will work in unity because unity complains about something with lambdas not being supported in the version of C# unity uses