Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arxone/mradvice
.NET aspect weaver (build task under NuGet package)
https://github.com/arxone/mradvice
advice aop aspects assembly inject-aspects
Last synced: 7 days ago
JSON representation
.NET aspect weaver (build task under NuGet package)
- Host: GitHub
- URL: https://github.com/arxone/mradvice
- Owner: ArxOne
- License: mit
- Created: 2015-01-31T16:06:34.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-11-28T08:06:05.000Z (24 days ago)
- Last Synced: 2024-12-15T09:00:11.527Z (7 days ago)
- Topics: advice, aop, aspects, assembly, inject-aspects
- Language: C#
- Homepage:
- Size: 7.23 MB
- Stars: 312
- Watchers: 30
- Forks: 45
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://en.wikipedia.org/wiki/Aspect-oriented_programming).Mr. Advice can weave assemblies for:
* .NET framework ≥4.6.1 / Mono
* .NET ≥5
* .NET Standard 2.0Mr. 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](https://img.shields.io/nuget/v/MrAdvice.svg?style=flat-square)](https://www.nuget.org/packages/MrAdvice) package. There is also an automatic build with tests at appveyor. The current status is [![Build status](https://ci.appveyor.com/api/projects/status/96i8xbxf954x79vw?svg=true)](https://ci.appveyor.com/project/picrap/mradvice)
## 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:
```csharp
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!```csharp
[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:
* [MrAdvice.MVVM](https://github.com/ArxOne/MrAdvice.MVVM) and its [NuGet package](https://www.nuget.org/packages/MrAdvice.MVVM/), an MVVM implementation using aspects.
* [Persistence](https://github.com/ArxOne/Persistence) and its [NuGet package](https://www.nuget.org/packages/ArxOne.Persistence/), a library that helps persisting properties in registry with a simple attribute.Miscellaneous projects:
* [The Blue Dwarf](https://github.com/picrap/BlueDwarf), a tunneling anti-censorship local proxy.
## Contact and links
Project owner is [picrap](https://github.com/picrap), feel free to drop a mail :email:.
Project company is [Arx One](https://arx.one), a french company editor of backup software solutions.