Coder Social home page Coder Social logo

Comments (5)

timeshift92 avatar timeshift92 commented on August 17, 2024

hi .net 8 added support for generics in annotations, is this a possible solution?

from aspect-injector.

pamidur avatar pamidur commented on August 17, 2024

hi!
It actually is. although idk how important this feature will be?
Do you have an use case where generic aspects are needed ?

from aspect-injector.

timeshift92 avatar timeshift92 commented on August 17, 2024

at the moment I'm looking for an opportunity to remove boxing and unboxing, so I thought maybe just the generics in the annotations will help with this, but I'm weak, so I can only guess

from aspect-injector.

pamidur avatar pamidur commented on August 17, 2024

you may be onto something, could you please me an example where boxing happens and how generics help?

from aspect-injector.

timeshift92 avatar timeshift92 commented on August 17, 2024
 [Mixin(typeof(INotifyPropertyChanged))]
    [Aspect(Scope.Global)]
    public class NotifyAspect : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged = (s, e) => { };

        [Advice(Kind.After, Targets = Target.Public | Target.Setter)]
        public void AfterSetter(
            [Argument(Source.Instance)] object source,
            [Argument(Source.Name)] string propName,
            [Argument(Source.Triggers)] Attribute[] triggers
            )
        {
            if (triggers.OfType<NotifyAttribute>().Any())
                PropertyChanged(source, new PropertyChangedEventArgs(propName));

            foreach (var attr in triggers.OfType<NotifyAlsoAttribute>())
                foreach (var additional in attr.NotifyAlso ?? new string[] { })
                    PropertyChanged(source, new PropertyChangedEventArgs(additional));
        }
    }

let's take your code, object is something universal, but in fact we can’t do anything with this object by type, we don’t bring it to what we need, both in notify and in interceptors, I think it would be convenient to do something like

  object[] Arguments to ArgumentList Arguments

for example, this object is to be replaced by a certain list of typed arguments, we would not spend on unboxin

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.