Urgent.News

What's breaking now, across hundreds of outlets.

Tech

How Nebula renames events and delegates

Rename a class and its methods and a decompiler still reads your event declarations almost verbatim — because a C# event is not one symbol. It is a small cluster of metadata that the compiler wires together for you, and a renamer that treats it as a single name either misses parts of the cluster or breaks the convention that holds it together. Get it wrong and the assembly still verifies but…

Nebula is a tool that renames events in a way that maintains their functionality. An event in C# is not just a single symbol, but a cluster of metadata consisting of an Event table row, add and remove accessor methods, and a private backing delegate field. The .event metadata directive ties these pieces together.

When renaming an event, Nebula treats it as a four-part unit, changing all four names simultaneously while preserving the association between them. The accessor methods and the backing field are renamed, while the token-based association remains intact. This ensures that the event continues to work correctly after renaming.

The backing field stores the current subscriber list, and the accessor methods are thread-safe. When an event is renamed, Nebula renames the event name, the add and remove accessor methods, and the backing field name in one step. This preserves the C# naming convention and keeps the association intact, allowing the Interlocked loop to continue functioning properly.

However, Renaming an event can break functionality if it is accessed by its string name instead of by token. This includes reflection-based subscription, type.GetEvent("Changed") returns null after rename, and any other code that relies on the string name of the event. To prevent this, a keep-list can be used to pin the event by its fully-qualified name, or the whole public contract can be excluded using an attribute.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

More from Dev.to on urgent.news

Report a problem with this story

Get the day's news by email. Daily, weekly or monthly. Sign up

More in Tech

More from Thursday, 3 December 2026 →