Menu

Why named tuples leak past obfuscation
📰

Why named tuples leak past obfuscation

DEV Community: csharp·Zero Heartbeat·11 days ago
#PHzTTpyV
#devtocsharp#devto#dev#blob#strings
Long article (1273 words) — no AI summary yet.
Reading 0:00
15s threshold

Run a .NET obfuscator over a library and open the result in a decompiler. Types collapse to a , b , c ; methods become single letters; fields are unreadable. Then you hit a method that returns a tuple, and the decompiler calmly prints (decimal balance, int openTrades, DateTime asOf) — every business-meaningful name intact, on a method now called a.b() . The renamer did its job on every identifier it could see. It never touched those names, because they were never identifiers.

The real question

Named tuples feel like they have members. You write result.balance and it compiles. So where does balance live, and why does a tool that rewrites every type, method, field and parameter name leave it alone?

The answer is that a named tuple has no runtime existence as a named thing at all . (decimal balance, int openTrades) is just System.ValueTuple<decimal, int> . Its only storage is the public fields Item1 and Item2 .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.