Coder Social home page Coder Social logo

mradvice's Introduction

Mr. Advice

Summary

Mr. Advice is an open source (and free of charge) alternative to PostSharp (which is still far more advanced, see https://www.postsharp.net).
It intends to inject aspects at build-time. Advices are written in the form of attributes, and marking methods with them makes the pointcut, resulting in a nice and easy aspect injection.
More information about what is an aspect at Wikipedia.

Mr. Advice can weave assemblies for:

  • .NET framework โ‰ฅ4.6.1 / Mono
  • .NET โ‰ฅ5
  • .NET Standard 2.0

Mr. Advice allows you to:

  • Advise methods or parameters, at assembly, type, method or parameter level
  • Advice types (at assembly startup)
  • Introduce fields
  • Advise Mr. Advice (and this is BIG) at weaving-time (during build step), so you can rename methods as they are advised, add properties, etc.

How it works

It is available as a NuGet Status package. There is also an automatic build with tests at appveyor. The current status is Build status

Philosophy

Currently, MrAdvice won't bring you any aspect out-of-the-box. This means you'll have to write your own aspects (however you can see below other packages using Mr. Advice).
So it brings us to the next chapter, which is...

How to implement your own aspects

In a nutshell

Here is the minimal sample:

public class MyProudAdvice : Attribute, IMethodAdvice
{
    public void Advise(MethodAdviceContext context)
    {
        // do things you want here
        context.Proceed(); // this calls the original method
        // do other things here
    }
}

You then just need to mark the method(s) with the attribute and that's it, your aspect is injected!

[MyProudAdvice]
public void MyProudMethod()
{
}

More details

Your aspects can be injected at assembly, type or method level, simply by setting the attribute:

  • When an aspect is injected at asembly level, all methods of all types are weaved.
  • When the aspect is injected at type level, all of its methods are weaved.
  • And of course, if the aspect is injected on a method, only the method is weaved.

Other projects using Mr. Advice

NuGet packages:

Miscellaneous projects:

Contact and links

Project owner is picrap, feel free to drop a mail ๐Ÿ“ง.
Project company is Arx One, a french company editor of backup software solutions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.