mvpete / aspekt Goto Github PK
View Code? Open in Web Editor NEWA lightweight (Aspect Oriented Programming) AOP foundation
License: MIT License
A lightweight (Aspect Oriented Programming) AOP foundation
License: MIT License
public override void OnEntry/OnExit/OnException
Aspekt needs the ability to capture, view and mutate return values of functions.
class QAspekt : Aspekt.Aspect
{
public override void OnException(MethodArguments args, Exception e)
{
Console.WriteLine($"Arguments: {args.Arguments.ElementAt(0).Value} Exception: {e.Message}");
}
}
[PropertyInvariant(nameof(DontNullMe), Contract.Constraint.NotNull)]
class ThrairPrinter
{
private string DontNullMe { get; set; } = "Q";
[QAspekt]
public void Print(String str)
{
DontNullMe = null;
Console.WriteLine(str);
}
}
Console
Hello World
Arguments: Hello World Exception: System.Void AspektTester.ThrairPrinter::set_DontNullMe() post-condition property 'DontNullMe' failed invariant value != null.
Feature to build and run on linux. Aspect needs the ability to build and run on linux.
Aspekt needs support for asynchronous code. So that it will function semantically as expected with async code.
Moving from C++ to C# has some perks like LINQ to ... well... whatever your heart desires. :)
Now while in this case it might not mean a huge performance increase, and I've only just started looking at the code, this will be a simple exercise and your code will look in some places a bit neater.
For example:
In your Bootstrap class, the first two methods:
HasCustomAttributeType you have this:
foreach (CustomAttribute attr in attributes)
{
if (attr.AttributeType.FullName == t.FullName)
return true;
}
return false;
Which with LINQ extensions would look like this:
private static bool HasCustomAttributeType(Collection<CustomAttribute> attributes, Type t)
{
return attributes.Any(attr => attr.AttributeType.FullName == t.FullName);
}
And then there's EnumerateMethodAttributes
This can be changed into a linq query, I have yet to understand properly the usage of this method but you could make it return IEnumerable and apply the action as you iterate. (an IEnumerable is not instantiated until it's needed, in this case I'm instantiating the collection by doing a ToList() on the query... this can be optimized.)
var query = (from types in module.Types
from methods in types.Methods
from customAttributes in methods.CustomAttributes
where pred != null && pred(customAttributes)
select new {Types = types, Methods = methods, CustomAttributes = customAttributes}).ToList();
query.ForEach(item =>
{
enumFn(item.Types, item.Methods, item.CustomAttributes);
});
Enhance Logging Aspect to have a logging service backend that can support different endpoints and levels. etc.
Adding advice to static functions generates invalid IL.
Aspekt needs the ability to alter flow control when faced with exceptions. i.e. returning a specific value, rethrowing exception, swallowing exception.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.