AOP framework for .NET (c#, vb, etc)
I have never asked for any donations, but today, I ask you, please, consider donating Ukrainian Army.
You can find official ways to do it here or you can donate to the biggest charity organization here
People need to be alive to create open source projects!
Aspect Injector is an attribute-based framework for creating and injecting aspects into your .net assemblies.
> dotnet add package AspectInjector"omnisharp.enableRoslynAnalyzers": true[Aspect(Scope.Global)]
[Injection(typeof(LogCall))]
public class LogCall : Attribute
{
[Advice(Kind.Before)] // you can have also After (async-aware), and Around(Wrap/Instead) kinds
public void LogEnter([Argument(Source.Name)] string name)
{
Console.WriteLine($"Calling '{name}' method..."); //you can debug it
}
}[LogCall]
public void Calculate()
{
Console.WriteLine("Calculated");
}
Calculate();$ dotnet run
Calling 'Calculate' method...
Calculatedpublic interface IInitializable
{
void Init();
}
[Aspect(Scope.PerInstance)]
[Injection(typeof(Initializable))]
[Mixin(typeof(IInitializable))]
public class Initializable : IInitializable, Attribute
{
public void Init()
{
Console.WriteLine("Initialized!");
}
}[Initializable]
public class Target
{
}
var target = new Target() as IInitializable;
target.Init();$ dotnet run
Initialized!No open issues yet, or sync has not completed.