Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any PostSharp alternative?

Tags:

.net

aspects

I have to abandon using PostSharp, because it won't work with obfuscated/merged assemblies. At least, I don't see any way to get it working (it crashes on app start, when assemblies are obfuscated)
I need to intercept some methods in my app (call special code instead of original methods - OnMethodInvocationAspect)
Any advice?

like image 783
skevar7 Avatar asked Jan 22 '23 22:01

skevar7


1 Answers

PostSharp somewhat supports ILMerge. See http://www.postsharp.org/blog/postsharp-and-ilmerge. But there are problems with obfuscated assemblies.

  1. Since aspects are serialized at build time, they cannot be deserialized if the aspect type has been obfuscated. The solution is not to obfuscate any serializable type. Another solution is not to serialize aspects (see AspectConfigurationAttribute.SerializerType in PostSharp 2.0, and use the serializer MsilAspectSerializer).

  2. There are problems when aspects are applied to generic methods and methods of generic types (the reason is that PostSharp uses reflection, based on method names, in this case, to work around bugs in the CLR).

like image 67
Gael Fraiteur Avatar answered Feb 04 '23 09:02

Gael Fraiteur