Coder Social home page Coder Social logo

aspectsharp's Introduction

AspectSharp

This is a PROOF OF CONCEPT project which intends to enable the Aspect-Oriented Programming (AOP) for C#.

The Aspect-Oriented Framework

Pointcuts Syntax

CodeGen and Meta-Programming

Extend instance class

public class Class
{
	public int Property { get; set; }
	public void Method() {  }
}

public class ClassExtension : ExtensionBase<Class>
{
	public ClassExtension(Class extension) : base (extension) {  }
	
	public int NewProperty { get; set; }
	
	public void NewMethod() 
	{
		Extension.Method();
	}
}

//somewhere in the source code
var c = new Class();
c.Property = 0;

//magic happens behind the scene
c.NewProperty = 0;
c.NewMethod();

The power of this idea is the integration with Design-Time and Background build from Visual Studio. This will allow the developer to see live changes in the Visual Studio.

How does it work? It is simple ...

  1. The developer creates a new extension class with ExtensionBase as a base class.
  2. Magic happens behind the scene (actually magic will happen in AspectSharp.targets and AspectSharp.Build.dll).
  3. The developer sees all the new properties/methods right to the extended class live in Visual Studio.

The magic

We are extending the MSBuild build process with our targets from AspectSharp.targets which will be applied right before compile. Our targets will find all extensions and then all extended classes. Based on the extensions new extended classes will be generated and included into the compiled files. Respectively original extended classes will be excluded from the compiled files. Therefore the generated extended classes will be included in the output assembly.

Visual Studio Design-Time build

Contributing

Anyone is welcome!

License

AspectSharp is distributed under the GPL-3.0 License.

aspectsharp's People

Contributors

eleanor68 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.