You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[assembly: LogAdvice]
[IncludePointcut("*Add")]
public class LogAdviceAttribute : Attribute, IMethodAsyncAdvice
{
public async Task Advise(MethodAsyncAdviceContext context)
{
Console.WriteLint("Entry");
await context.ProceedAsync();
Console.WriteLint("Exit");
}
}
If I understand correctly when we build the project, Weaver will check all methods in assembly and if their full name matches "*Add" it will advice it.
This is good, but I need more than just name checking for advice. for example I want to advice all private methods that their output is int.
This is what I have in my mind :
public interface IPointcutSelector
{
bool ShouldAdvice(MethodInfo methodInfo);
}
public class PointcutSelectorAttribute : Attribute, IPointcutSelector
{
public bool ShouldAdvice(MethodInfo methodInfo)
{
return methodInfo.IsPrivate && methodInfo.ReturnType == typeof(int);
}
}
Can we have this? :)
The text was updated successfully, but these errors were encountered:
Currently, not. This is a recurring problem I have, where Mr. Advice weaver would need to load the weaved assembly, regardless the platform. Mr. Advice weaver uses .NET framework 4.5, but since you can weave assemblies for many platforms (Silverlight, or anything from .NET standard 1.5), the weaver can not load assembly from any other platform, so I need to solve this in order to allow such extensibility. Any idea welcome 😉
This probably can be done once the number of targets is reduced to two, which are .NET framework 4.0 and .NET Standard 2.0 (if this one is supported by other frameworks).
Let's say we have a code like this :
If I understand correctly when we build the project, Weaver will check all methods in assembly and if their full name matches
"*Add"
it will advice it.This is good, but I need more than just name checking for advice. for example I want to advice all
private
methods that their output isint
.This is what I have in my mind :
Can we have this? :)
The text was updated successfully, but these errors were encountered: