Add optional decompiler hook for custom member display names in tree nodes#495
Add optional decompiler hook for custom member display names in tree nodes#495geocine wants to merge 1 commit into
Conversation
|
Hello, This addition seems a lot like a hack fix rather than an actual solution. The API is currently inconsistent with the The interface name I'm also generally opposed to adding such hacky interfaces or APIs that are designed for one specific extension implementation. |
This is intended as a generic extensibility fix for custom decompilers, not a behavior change for built in dnSpy decompilers
Problem
Today, dnSpy tree labels for some member kinds still use raw metadata names directly in
NodeFormatterinstead of asking the active decompiler for a display name.That means custom decompilers or decompiler decorators can change names in decompiled output, but the document tree on the left can still show the original metadata names. The result is inconsistent UI between the tree and the decompiled text.
Solution
This PR adds a new optional interface:
IDecompilerMemberNameProviderand updates
NodeFormatterto use it for member kinds where the tree currently hardcodes metadata names:I wanted to keep the change generic and non invasive:
Impact
For built in dnSpy behavior, this should be a noop unless a decompiler explicitly implements the new interface.
For custom decompilers/decorators, this makes it possible to keep the document tree labels consistent with the names shown in decompiled output.
This is also useful for plugin development where decompiler behavior is extended outside upstream dnSpy. In my case, this helps sourcemap name remapping stay consistent between the decompiled text and the document tree without carrying a larger fork specific patch in dnSpy core.