mkaring / ConfuserEx

An open-source, free protector for .NET applications
https://mkaring.github.io/ConfuserEx/
MIT License
2.31k stars 350 forks source link

Copy custom attributes from origin to injected type #428

Closed oSumAtrIX closed 2 years ago

oSumAtrIX commented 2 years ago

Delegate types require custom attributes to function properly on some occasions.

AppVeyorBot commented 2 years ago

:white_check_mark: Build ConfuserEx 889 completed (commit https://github.com/mkaring/ConfuserEx/commit/9d96bb52cb by @oSumAtrIX)

AppVeyorBot commented 2 years ago

:white_check_mark: Build ConfuserEx 891 completed (commit https://github.com/mkaring/ConfuserEx/commit/c52e01dd00 by @oSumAtrIX)

mkaring commented 2 years ago

@oSumAtrIX: I get the general reason why you want to fix this. Is there a specific type that is injected where this fails? I did not notice any errors in this regard.

In any case the injection of CustomAttribute is implemented twice, any both times not correct, if I merge the current version of your pull request.

One time it's done in CopyTypeDef and the second time in CopyMethodDef.

It would be great if your could implement a general CopyCustomAttributes method that handles the injection for custom attributes for both cases correctly. The shared interface to access those attributes is IHasCustomAttribute To fully copy the CustomAttribute you need to handle the Constructor (as you do already) as well as the ConstructorArguments and the NamedArguments. The Constructor only declares the type of the attributes itself, the types and values of the arguments are still missing.

mkaring commented 2 years ago

Closing the PR. Seems abandoned.