Why Custom Attributes in .NET Give Me Nightmares

Even .NET fans are fed up as coders roast a feature they call pure chaos

TLDR: A .NET expert says a common code-labeling feature is designed in a deeply frustrating way that makes low-level tools miserable to build. Commenters split between “this is only a problem for specialists” and “no, this whole pattern is a red flag,” turning a niche complaint into a wider fight about messy software design.

A .NET developer basically showed up to the internet saying, “I love this platform, but this one feature is cursed,” and the crowd absolutely ran with it. The complaint? Custom attributes — little labels developers attach to code so tools and compilers know what to do — sound harmless, but under the hood they’re stored in a way the author says has caused years of misery. This isn’t a casual gripe either: the writer maintains a library for reading program files and says these attributes have become such a recurring disaster that they’re now a running meme among maintainers. In other words: not a bug, a lifestyle.

And the comments? Deliciously divided. One camp basically shrugged and said, if you’re just using normal built-in tools like reflection, none of this pain matters — a classic “works on my machine” energy. Another group went much harder, arguing that attributes are a bad way to control real app behavior in the first place, because they’re too limited and quickly turn into fragile, hard-to-follow magic. Others piled on with broader anti-reflection snark, calling it a “code smell” beloved by beginners right before everything gets weird.

Then came the spicy side quests: one commenter wondered if this whole mess is part of why .NET apps can feel slow to start, while another joked that maybe this is why JavaScript never really embraced the idea. The overall mood? Powerful, painful, and somehow still everybody’s problem.

Key Points

  • The article examines how custom attributes are stored in .NET binaries and argues that the storage design is problematic.
  • Custom attributes are metadata attached to classes, methods, fields, parameters, and other program elements, and can influence compiler behavior or tooling.
  • In the .NET file format, custom attributes are stored in a CustomAttribute metadata table, alongside references to the annotated member, the attribute constructor, and a blob containing serialized arguments.
  • Custom attribute arguments are serialized sequentially in binary form according to the constructor parameter types.
  • The article highlights enum-valued attribute parameters as a point where the serialization design becomes more difficult because enums are encoded using their underlying type.

Hottest takes

"If you're just trying to handle them with reflection none of this is an issue" — pjc50
"powerful but painfull" — tracker1
"When I come across reflection code it's often a smell" — gwbas1c
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.