Skip to content
Tony THONG edited this page Mar 16, 2017 · 8 revisions

Presentation

NConcern is a .NET runtime AOP (Aspect-Oriented Programming) lightweight framework written in C# that reduces tangling caused by cross-cutting concerns. Its role is to introduce Aspect-Oriented Programming paradigm with a minimum cost to maximize quality and productivity.

NConcern is based on code injection and advanced .net Framework novelties to allow a bunch of exclusives features :

  • non-intrusive : no need to change the source code or the publishing process.
  • friendly : delegates, expressions (linq) or CIL (ILGenerator) can be used to define an aspect
  • no configuration : additional configuration files are not required
  • no proxy : decoration by inheritance and factory pattern are not required
  • low learning curve : get started under 20 minutes
  • no installer : single .net library (.dll) to reference
  • suited for unit testing : weaving is controlled at runtime
  • low performance overhead : injection mechanic is built to be efficient
  • limitless : everything except generic methods is supported (coming with next release)
  • runtime lifecycle : aspect can be updated/created/removed at runtime

Roadmap

CNeptune is prioritize because it will be a requirement for NConcern and will fix all known issues and bring features

  • Interception for generic methods
  • Late bound methods
  • Module construction trigger
  • Class constructor trigger
  • External virtual methods dispatch

Guide

Publication

#FAQ

  • How this AOP Framework is different from the others? Most of time developping cross-cutting source code required reflection and boxing to be done. NConcern offer a way to define it using Linq Expressions or ILGenerator because cross-cutting source code have to manage not statically known datas. No need factory and no need base class is the second exclusive feature that make the difference because interception is i not based on method overriding or ContextBoundObject.
  • How fast is "low performance overhead"? For real there is no overhead when Linq Expressions or ILGenerator are used. Basic advice introduce a light overhead caused by boxing and arguments array creation. However, MethodInfo is not prepared if capture in not required in lambda expression.
  • Why I have to use DebuggableAttribute? Interception is based on method swaping and cannot be applied when JIT or compiler optimize a call by inlining. The DebuggableAttribute is an acceptable way to disable inlining without being to much intrusive. You are free to do it by another way but keep in mind that only non virtual methods can be inlined.
  • Can I add multiple aspect for same taget? if yes how can I control priority? Yes you can. Priority is defined by the order of weaving. It can be reorganized by calling Aspect.Release(...)/Aspect.Weave(...) and you can check the whole aspects mapping by calling Aspect.Lookup(...)
  • Is an attribute required to identify a mehod to weave? No you can identify a method by the way you want. There is a Aspect.Weave(...) overload that take a Func<MethodInfo, bool> to select methods.
  • Can I intercept constructor? If yes, how do I implement it? Constructor interception is supported and is treated like another method with declaring type as first argument and void for return type.