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

Move Attribute to interface #5

Open
phonglt7 opened this issue Jun 8, 2019 · 2 comments
Open

Move Attribute to interface #5

phonglt7 opened this issue Jun 8, 2019 · 2 comments

Comments

@phonglt7
Copy link

phonglt7 commented Jun 8, 2019

Hi, I've used your lib recently and it works great.
While using, I see that it's not a good practice to add the Attribute to the Class, I wonder if you can support then I can declare it in Interface?

Like this:

public interface MyInterface()
{
    [MyInterceptorAttribute]
    void MyMethod();
}

public class MyClass() : MyInterface
{
    void MyMethod()
    {
    }
}
@f135ta
Copy link
Owner

f135ta commented Jun 8, 2019

Hello,
It’s my understanding that interfaces define contracts and are implemented by classes. The attributes applied to an interface wouldn’t be inherited or transferred in any way to the class. The way I have CastleProxy configured requires that the class is used with the attributes so that it can be wrapped and intercepted. I don’t see a way for that to work with the current setup. Do you have a proposal for how it might?

@phonglt7
Copy link
Author

phonglt7 commented Jun 9, 2019

In my case, I want it to set in interface so any class implements it will be intercepted by the attribute, so the developers won't need to remember to put the attribute to their classes.
And I see your point, then I could try to set the attribute to the base class to take advantage of the inheritance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants