Closed heralight closed 2 years ago
What is my advice using MrAdvice, mmmh? š Iām not sure I understand your question: do you want to inject aspect to dotnet code or to yours? The first is not possible (MrAdvice works at post-build step, so it needs you to do the build), the second is simply achieved by applying the advice (itās an attribute youāll write) at the requested point (method, class, even whole assembly). Does this help?
Hi there,
Great work indeed!
I think he's trying to understand how to inject dependencies (e.g. a logger class) into an aspect.
Considering the aspect works at compile time, that should not be possible, I guess.
I noticed that on PostSharp's aspects is possible to add a runtime initialization which can be used to then obtain and use dependencies.
Is there something similar available in MrAdvice?
Thanks
What do you mean by āruntime initializationā? There are aspects in MrAdvice that are related to reflection, such as IMethodInfoAdvice
and IPropertyInfoAdvice
, they are invoked once per reflection element.
How would you imagine the feature you want?
I've bumped into this post and noticed the RuntimeInitialize method exposed by PostSharp. In the above question the guy that posted is manually creating instances of the required dependency at runtime initalization and the 1st answer shows a better pattern to achieve the requirement. Either way, it's all possible because of the RuntimeInitialization method in the aspect.
Hi everyone. I like this discussion, so feel free to join discussion #179 š
Join #179!
Hi!
Great work with MrAdvice!
I would like to use it in dotnet core 5 aspnet project to simplify serilog (logger) code, simplify some EF query through attributes, ...etc. The problem that I can't actually solve is how to access to dotnet core logger, ef context, ...etc. Do I need to do it through some reflection at startup and get the instances from some properties, what is your advice or perhaps have already some code to do that please?
Thank you !
Alexandre