ArxOne / MrAdvice

.NET aspect weaver (build task under NuGet package)
MIT License
311 stars 45 forks source link

Problem with public structs #149

Closed rhap06 closed 5 years ago

rhap06 commented 5 years ago

Hi,

We have some public structs declared in our project that is using MrAdvice and it seems the Assembly doesn't have those struct anymore when we build it. I have this struct: public struct ExempleKeyPair<TItemId, TItem> with these properties: public readonly TItemId ItemId; public readonly TItem Item;

and this constructor: public ExempleKeyPair(TItemId itemId, TItem item) { ItemId = itemId; Item = item; }

When I do this call : new ExempleKeyPair<int, string>(itemId, item) I get this error when my advice is in the project System.TypeLoadException: Could not load type 'Application.BLL.Common.ExempleKeyPair``2' from assembly If I put [ExcludeAdvices("*")] on the struct it works. Also, if I change the type to a class it works. So, there seems to be a problem with structs. I couldn't use ExcludePointcutAttribute to filter the struct. I'm currently using the version 2.8.5 but I also tried with 2.8.4.

I could put [ExcludeAdvices("*")] on every structs but I don't want to modify all structs for the code to work. Could you tell me if there's another way of if there could be a fix for that?

Thanks,

picrap commented 5 years ago

Thanks for reporting, I'll take a look. EDIT: did you try on non-generic structs?

rhap06 commented 5 years ago

Hi!

Sorry for the delay, yes I tried it and it works. It only happens when you try to have a generic struct, like a key pair.

picrap commented 5 years ago

I took a look at the code, and all generics were ignored (there was even a comments saying that I don't know how to handle them). This should be fixed in 2.8.6. Please let me know and close this issue if it is the case.

rhap06 commented 5 years ago

I confirm it's now working in 2.8.6. Thanks a lot for the quick fix!

picrap commented 5 years ago

Thanks for reporting the issue!