All Projects → pamidur → Aspect Injector

pamidur / Aspect Injector

Licence: apache-2.0
AOP framework for .NET (c#, vb, etc)

Projects that are alternatives of or similar to Aspect Injector

Puresharp
Puresharp is a Framework that provides the essential APIs (AOP, IOC, etc...) to productively build high quality (.NET 4.5.2+ & .NET Core 2.1+) applications through reliability, scalability and performance without no compromise
Stars: ✭ 120 (-69.85%)
Mutual labels:  advice, aop, injection
Nconcern
NConcern .NET AOP Framework
Stars: ✭ 139 (-65.08%)
Mutual labels:  advice, aop, injection
Colore
A powerful C# library for Razer Chroma's SDK
Stars: ✭ 121 (-69.6%)
Mutual labels:  wrapper, dotnet-core
Dntframeworkcore
Lightweight and Extensible Infrastructure for Building Web Applications - Web Application Framework
Stars: ✭ 208 (-47.74%)
Mutual labels:  dotnet-core, aop
Mradvice
.NET aspect weaver (build task under NuGet package)
Stars: ✭ 236 (-40.7%)
Mutual labels:  advice, aop
Go Dotnet
Go wrapper for the .NET Core Runtime.
Stars: ✭ 369 (-7.29%)
Mutual labels:  wrapper, dotnet-core
Rocksdb Sharp
.net bindings for the rocksdb by facebook
Stars: ✭ 173 (-56.53%)
Mutual labels:  wrapper, dotnet-core
AnnotationInject
Compile-time Swift dependency injection annotations
Stars: ✭ 40 (-89.95%)
Mutual labels:  injection, compile-time
NCop
Composite-aspect oriented framework for .NET
Stars: ✭ 30 (-92.46%)
Mutual labels:  mixins, aop
CNeptune
CNeptune improve productivity & efficiency by urbanize .net module with meta-code to lay foundation for frameworks
Stars: ✭ 30 (-92.46%)
Mutual labels:  injection, aop
refuel
Lightweight dependency injection engine and DI-driven tools.
Stars: ✭ 21 (-94.72%)
Mutual labels:  injection, compile-time
Storage
💿 Storage abstractions with implementations for .NET/.NET Standard
Stars: ✭ 380 (-4.52%)
Mutual labels:  dotnet-core
Sparqlwrapper
A wrapper for a remote SPARQL endpoint
Stars: ✭ 365 (-8.29%)
Mutual labels:  wrapper
Pytorch Custom Cuda Tutorial
Tutorial for building a custom CUDA function for Pytorch
Stars: ✭ 369 (-7.29%)
Mutual labels:  wrapper
Ngx Cookie Service
Angular (4.2+ ...11) service for cookies. Originally based on the `ng2-cookies` library.
Stars: ✭ 363 (-8.79%)
Mutual labels:  aot
Managers Playbook
📖 Heuristics for effective management
Stars: ✭ 4,504 (+1031.66%)
Mutual labels:  advice
Proselint
A linter for prose.
Stars: ✭ 3,836 (+863.82%)
Mutual labels:  advice
Static Assertions Rs
Ensure correct assumptions about constants, types, and more in Rust
Stars: ✭ 363 (-8.79%)
Mutual labels:  compile-time
Cuda Api Wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
Stars: ✭ 362 (-9.05%)
Mutual labels:  wrapper
Admin.core
Admin后端,前后端分离的权限管理系统,集成统一认证授权,支持国内外主流数据库自由切换和动态高级查询,基于.Net开发的WebApi
Stars: ✭ 358 (-10.05%)
Mutual labels:  dotnet-core

Aspect Injector

Aspect Injector is an attribute-based framework for creating and injecting aspects into your .net assemblies.

Project Status

Nuget Nuget Pre GitHub (Pre-)Release Date GitHub last commit

Application Status Samples Status

Download

> dotnet add package AspectInjector

Features

  • Compile-time injection - works with Blazor and AOT
  • Injecting Before, After and Around (wrap) Methods, Constructors, Properties and Events
  • Injecting Interface implementations
  • Supports any project that can reference netstandard2.0 libraries, see here
  • Debugging support
  • Roslyn analyzers for your convenience (only c# currently)

Check out samples and docs

Requirements

  • .NetCore runtime 2.1.6+ installed on your machine (your projects can be anything that can reference netstandard2.0)
  • (optional) For analyzers to work in VSCode, don't forget to enable "omnisharp.enableRoslynAnalyzers": true

Known Issues / Limitations

  • 'Edit and Continue' feature in VS is not working at the moment with .netcore3+ #138
  • Unsafe methods are not supported and are silently ignored.
  • Until Nuget v5 (with transient build feature) you need to refrecence AspectInjector into every project in your solution. Thus,
    if VisualStudio >= 2019 && CoreSDK >= 2.1.602
        no worries about references
    else 
        reference AspectInjector directly to projects where aspects are defined or used

Simple advice

Create an aspect with simple advice:

[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	
    }
}

Use it:

[LogCall]
public void Calculate() 
{ 
    Console.WriteLine("Calculated");
}

Calculate();

Result:

$ dotnet run
Calling 'Calculate' method...
Calculated

Simple mixin

Create an aspect with mixin:

public interface IInitializable
{
    void Init();
}

[Aspect(Scope.PerInstance)]
[Injection(typeof(Initializable))]
[Mixin(typeof(IInitializable))]
public class Initializable : IInitializable, Attribute
{
    public void Init()
    {
        Console.WriteLine("Initialized!");
    }
}

Use it:

[Initializable]
public class Target
{ 
}

var target = new Target() as IInitializable;
target.Init();

Result:

$ dotnet run
Initialized!
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].