Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advice on methods of child class #202

Open
mmarjano opened this issue Feb 16, 2024 · 1 comment
Open

Advice on methods of child class #202

mmarjano opened this issue Feb 16, 2024 · 1 comment
Labels

Comments

@mmarjano
Copy link

mmarjano commented Feb 16, 2024

Hello,

I have my Advice as this:

public class MyProudAdvice : Attribute, IMethodAdvice
{
    public void Advise(MethodAdviceContext context)
    {
        // do things you want here
        context.Proceed(); // this calls the original method
                           // do other things here
    }
}

I have my Controller base class like this:

[MyProudAdvice]
public abstract class BaseController : Controller
{
}

My HomeController inherits BaseController.

The problem is, Advise method is triggered only for constructor of HomeController, not for the Index method. If I move MyProudAdvice attribute directly to HomeController, then Advise method is correctly triggered for all methods of HomeController. How can I achieve this using my base controller class? In PostSharp this was achieved using AttributeInheritance = PostSharp.Extensibility.MulticastInheritance.Multicast, but I see no similar option in documentation.

Thank you!

@picrap
Copy link
Member

picrap commented Feb 21, 2024

Hi,

If the advice attribute is inherit (which is the case by default), it should work.
Otherwise, this seems to be a bug, I’ll take a look.

@picrap picrap added the bug label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants