Git Product home page Git Product logo

Comments (6)

christianacca avatar christianacca commented on July 18, 2024

Couldn't figure out how to make a second pull requests whilst I have one already outstanding against the master repository. Anyhow, my change is here.

As you will see from the my commit, I left in the original code that searches the context for the name of the function, but this code is only executed when the methodName is not already remembered in advance.

I have looked at your fix to this problem here and note that you're doing something similar. Myself, I wasn't confident enough to remove altogether the search of the context for the method name.

Christian

from angular-aop.

mgechev avatar mgechev commented on July 18, 2024

Please verify whether the issue is fixed after the merge to close it.

from angular-aop.

christianacca avatar christianacca commented on July 18, 2024

Hi Minko,

I don't think including the methodName in the list of arguments is working. What I'm seeing is the methodName repeated multiple times in the args parameter supplied to the advice. I think the problem occurs when you have multiple aspects being applied to the same function.

For example, I have some code that adds a tracing aspect to a matching function:

subject = execute(trace.error).onThrowOf(subject, methodMatcher);
            subject = execute(trace.begin).before(subject, methodMatcher);
            subject = execute(trace.end).after(subject, methodMatcher);

The end result of the above code is an Aspect[POINTCUTS.AFTER] wrapping an Aspect[POINTCUTS.BEFORE] wrapping an Aspect[POINTCUTS.ON_THROW]. Each of these wrappers adds the methodName to the arguments that eventually get passed to the original function and hence the duplication of method name.

I think you will have to do what I did, or something similar: store the methodName on the Aspect instance itself. As a reminder this is my commit that shows how I coded this.

Also I can see other bugs in the promise related join points. I will supply a fix for those once we've moved forward from this issue.

Christian

from angular-aop.

mgechev avatar mgechev commented on July 18, 2024

Thank you for the feedback!

Yesterday I merged your changes for the promise related fixes so I think they should be ok now.

Now I hope that everything is fixed. I had about an hour and I think I found the base problem which was connected with the arguments passing and simple problem in _getMethodName which was getting the name of the wrapper instead of the base function.
There was also an issue when afterResolveOf is used with onRejectOf. In afterResolveOf new promise is created which wasn't rejected when needed.

Another change is that few new properties are added to the advices parameters:

  1. resolveArgs
  2. rejectArgs

I think they might be useful in some cases.

Please let me know if there are still existing problems.

from angular-aop.

christianacca avatar christianacca commented on July 18, 2024

Great Minko. I've tested the latest code and the fix seems to work nicely.

I'm going to make a couple of more suggestions, but this particular issue I think can be closed.

from angular-aop.

mgechev avatar mgechev commented on July 18, 2024

OK. I'm closing it.

from angular-aop.

Related Issues (12)

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.