ArxOne / MrAdvice

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

Exception caused when method returns a task #150

Closed rhap06 closed 5 years ago

rhap06 commented 5 years ago

Hi,

I've got a really weird bug with MrAdvice. I made a BaseAdvice Abstract class and I have an assembly advice inheriting from it. I've got no problems setting the IncludePointcutAttribute and ExcludePointcutAttribute on my assembly advice. Everything works except when I don't include a method that returns a task. Whenever I do the Task.Start() I get the following exception : System.InvalidOperationException: 'Start may not be called on a continuation task.'

That only happens when you exclude it on the assembly advice. If I include it, it works. If I add [ExcludeAdvices("*")] on my class the contains the method, it works. Also, if I add the ExcludePointcutAttribute on my BaseAdvice class, it also works. That's really strange. Here's the code I made to show the problem: TestConsole.zip

Thanks!

picrap commented 5 years ago

Weird indeed... I'll take a look at it.

rhap06 commented 5 years ago

Hi, did you have a time to take a look by any chances?

picrap commented 5 years ago

Sorry, no.

picrap commented 5 years ago

Confirmed, there are two bugs:

  1. The method shouldn't be weaved
  2. It should not throw exception, event if mistakenly weaved
picrap commented 5 years ago

This should be fixed in 2.8.7. Let me know.

rhap06 commented 5 years ago

Thanks a lot! I confirm everything is now working correctly!