Coder Social home page Coder Social logo

aspekt's People

Contributors

brantburnett avatar jpdillingham avatar mvpete avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

aspekt's Issues

PropertyInvariant exception is being caught in Core.Aspekt OnException handler

   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.

[Enhancement] Linq to objects is cool!

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);
});

Exception Flow Control

Aspekt needs the ability to alter flow control when faced with exceptions. i.e. returning a specific value, rethrowing exception, swallowing exception.

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.