GithubHelp home page GithubHelp logo

Comments (4)

Dreamescaper avatar Dreamescaper commented on June 11, 2024 1

According to SharpLab, it compiles to smth like this:

    [CompilerGenerated]
    internal unsafe static Func<object> <<Main>$>g__Del4|0_3(object o)
    {
        return new Func<object>(o, (nint)(delegate*<object, object>)(&Helper.This));
    }

But I cannot write such code manually, I can't even find Func constructor with two parameters.

from mobileblazorbindings.

Dreamescaper avatar Dreamescaper commented on June 11, 2024

Tricky thing here is that delegates, created for the same object, should be considered equal.
That is possible with regular static method, but requires using reflection and is much slower (probably neglectable for our needs, but anyway):

https://sharplab.io/#v2:EYLgtghglgdgNAFxAJwK7wCYgNQB8ACATAIwCwAUBQG4TIAEAzgvQLx0BExhAzACwCs7ANwUAIgFMANsQAUTZAEoAdAFEAjqgiSGMidLnMFygJIwGAB3EBjBDIUjyewgcWqNWnU5dGlpi9dt7MSlubzdNbV0Q7xMzSxs7Bz1eMPUIzykU+R8/eMCHCnx+AB4Ae2AAKwCAPjo9WQB5SoC6UoU6Flq7DtrShyKy5ptaryaqm1b2zrpu6YAJKUtkJQAlcQBzVElaGTb+kvLxhBHosZa2npmBw5qFPQ2IBHElAGFkcUfxe/XPmQQAT0spQAZjJrkNjgo4K1oQCgaCFpIlsoAOLiBAAWXRAAtShgZOw1pttsh2EZ9oMjidJCkzhMLtNSkoACrYqAMAqUcj4bh0fDEABsfMIdERSwoAG8KHQZXzefyhTcJqz2X82QxWhDJpc+tLZTy+YLNUc6EStjslQhtYyHABfIA

from mobileblazorbindings.

Eilon avatar Eilon commented on June 11, 2024

Interesting, that is definitely something to consider. I wonder if there's some clever syntax to avoid reflection and have the compiler provide the delegate with the right identity? It's just so unusual for extension methods to provide any concrete benefit aside from the compiler syntax sugar!

from mobileblazorbindings.

Eilon avatar Eilon commented on June 11, 2024

Anyway, this is hardly a big matter, I just don't like extension methods on object 😁

from mobileblazorbindings.

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.