Is it possible to intercept class constructor and destructor calls using PostSharp? I would like to create active instances counter for classes.
Is it possible to intercept class constructor and destructor calls using PostSharp? I would
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use OnMethodBoundaryAspect on constructor and destructors. Note that classes don’t have destructors by default in C# and VB, and destructors are called at a non-deterministic moment.
Remember that constructors can be called in chain, and the aspect is going to be applied on every constructor in the chain.