Coder Social home page Coder Social logo

Comments (5)

pamidur avatar pamidur commented on August 17, 2024

Thanks for the report. Although I can reproduce this issue I don't have a full picture of the way it should be fixed.
So if you have instance of non-static class - you get it via AdviceArgumentSource.Instance
But What is supposed to be returned in case of static class? Null? Exception?
typeof(non-static-class) would a bit inconsistent here. wouldn't it?
Any thoughts ?

from aspect-injector.

kazachis4e avatar kazachis4e commented on August 17, 2024

I think in static case Instance must return null, not Exception. But in this case too little information about static method. So in my opinion there is two options:
1. Add new AdviceArgumentSource property, e.g. TargetMethod, with MathodBase (or MethodInfo) type. If aspect marked with InjectionTargets.Method (and may be InjectionTargets.Constructor) - fill this property. In another InjectionTargets - this property is null.
2. Replace AdviceArgumentSource.TargetName to AdviceArgumentSource.MemberInfo with MemberInfo type. In aspect body MemberInfo can be casted to Methodinfo or PropertyInfo according InjectionTargets. Removed TargetName can be getted from MemberInfo.

from aspect-injector.

pamidur avatar pamidur commented on August 17, 2024

The point is that retrieving MemberInfo has huge performance impact because of runtime reflection. And TargetName is well known in compile time. May be we could leave both TargetName and TargetMember. So in case of property TargetName would be "SomeProperty" and TargetMember would be memberinfo of set_SomeProperty.
Though there is one requirement - stick with portable subset of .net

from aspect-injector.

pamidur avatar pamidur commented on August 17, 2024

Fixed in 0.9.44.
I made it return null when member is static and instance is requested.
I also added new AdviceArgumentSource.Type so can access target type now. I guess you can handle retrieving member-infos with AdviceArgumentSource.Type + AdviceArgumentSource.TargetName for now.

I'll also create an improvement issue on backlog about something like AdviceArgumentSource.TargetMember. I hope we will find a way to make it fast and efficient.

from aspect-injector.

kazachis4e avatar kazachis4e commented on August 17, 2024

Very big thanks!!! Now this project completely satisfied my requirements )

from aspect-injector.

Related Issues (20)

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.