Menu

Decompiling allows ref struct: the whole feature is one metadata bit, and dropping it silently narrows your contract
📰

Decompiling allows ref struct: the whole feature is one metadata bit, and dropping it silently narrows your contract

DEV Community: dotnet·Zero Heartbeat·about 20 hours ago
#tPyWPyjc
#devtodotnet#devto#dev#struct#constraint
Reading 0:00
15s threshold

Most C# language features leave a trail in the instruction stream. An async method becomes a state machine you can single-step; a yield return becomes a MoveNext with a jumped-to label; even a using is just a try / finally around a Dispose . A decompiler earns its keep by reading those instructions and folding them back into the syntax that produced them.

The C# 13 allows ref struct anti-constraint is the opposite kind of feature. It produces no method-body IL whatsoever . The entire feature is one bit in one metadata table, set on one generic parameter. That makes it one of the cleanest case studies there is for why a decompiler has to read metadata as carefully as it reads code — because here the code says nothing, and a tool that only reads code will hand you source that compiles, runs identically, and is quietly wrong. This post walks the construct for Glass.NET , the free .NET decompiler.

An anti-constraint, not a constraint

A normal generic constraint adds a requirement.…

Continue reading — create a free account

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