When cloning individual properties or events with MemberCloner.Include(PropertyDefinition) or MemberCloner.Include(EventDefinition), the cloned members aren't added to the resulting MemberCloneResult.
This behavior is inconsistent with what happens when cloning fields or methods, which are accessible in MemberCloneResult, and not automatically added to their declaring type.
When the declaring type isn't cloned, the only workaround to get back a reference to those cloned members is to register a custom IMemberClonerListener to the MemberCloner instance, implementing the OnClonedProperty(PropertyDefinition original, PropertyDefinition cloned) or OnClonedEvent(EventDefinition original, EventDefinition cloned) methods.
How To Reproduce
Clone individual properties or events with MemberCloner.Include()
Call MemberCloner.Clone()
Expected Behavior
The resulting MemberCloneResult has references to the original and cloned properties or events.
The cloned properties or events aren't automatically added to their declaring type when that type was also explicitly cloned.
Actual Behavior
The resulting MemberCloneResult doesn't have any reference to either the original or cloned properties or events.
The cloned properties or events are automatically added to their declaring type when that type was also explicitly cloned.
AsmResolver Version
5.5.1.0
.NET Version
.net standard 2.0
Operating System
Windows
Describe the Bug
When cloning individual properties or events with
MemberCloner.Include(PropertyDefinition)
orMemberCloner.Include(EventDefinition)
, the cloned members aren't added to the resultingMemberCloneResult
.Additionally, and contrary to what the documentation says :
Cloned properties and events are actually injected in their
DeclaringType
, but only if that type was explicitly cloned too usingMemberCloner.Include(TypeDefinition)
(or one of its variants) : https://github.com/Washi1337/AsmResolver/blob/f70da7936c203b4ecfb19c9ad71d08c6eb4b5bd3/src/AsmResolver.DotNet/Cloning/MemberCloner.Semantics.cs#L13-L19 https://github.com/Washi1337/AsmResolver/blob/f70da7936c203b4ecfb19c9ad71d08c6eb4b5bd3/src/AsmResolver.DotNet/Cloning/MemberCloner.Semantics.cs#L50-L56This behavior is inconsistent with what happens when cloning fields or methods, which are accessible in
MemberCloneResult
, and not automatically added to their declaring type.When the declaring type isn't cloned, the only workaround to get back a reference to those cloned members is to register a custom
IMemberClonerListener
to theMemberCloner
instance, implementing theOnClonedProperty(PropertyDefinition original, PropertyDefinition cloned)
orOnClonedEvent(EventDefinition original, EventDefinition cloned)
methods.How To Reproduce
MemberCloner.Include()
MemberCloner.Clone()
Expected Behavior
MemberCloneResult
has references to the original and cloned properties or events.Actual Behavior
MemberCloneResult
doesn't have any reference to either the original or cloned properties or events.