Skip to content

Update metadata when entities are deleted by an EnC edit #75154

@tmat

Description

@tmat

Roslyn now allows to delete type members. Deleted method bodies are updated to throw MissingMethodException or to call to the new method (WIP). The deletions are however not reflected in metadata returned by Reflection which may affect app frameworks that depend on Reflection information.

Consider adding a naming convention for names of deleted members that Roslyn can use to mark deleted members and that Reflection skips over when enumerating type members.

UPDATE:
Currently proposed convention is to add deleted_ prefix to the member name and set SpecialName flag to true. Applies to MethodDef, Property and Event metadata table entries.

UPDATE:
Turns out renaming the members would have side effects that are not desirable. Specifically, when a method is referenced via MemberRef and the referencing IL is jit-compiled after the member has been deleted, the runtime throws MissingMemberException exception. However, we want the deleted member's body to be called so that it throws HotReloadException.

Instead of renaming the deleted member we mark it with an attribute: System.Runtime.CompilerServices.ReflectionHiddenAttribute

or define Hidden flags in

FieldAttributes
MethodAttributes
PropertyAttributes
EventAttributes
TypeAttributes

#118903

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions