Giter Site home page Giter Site logo

Overloaded method support about refit HOT 4 CLOSED

reactiveui avatar reactiveui commented on May 5, 2024
Overloaded method support

from refit.

Comments (4)

bennor avatar bennor commented on May 5, 2024

Yeah I was wondering about this when you added the warning for it. It adds a bit of complexity to RequestBuilderImplementation and the stub generation (and would mean a bit of duplication), but it would be good to allow the interface to match a Web API class almost 1 to 1.

@paulcbetts, can you think of any reason why this would be a bad idea?

from refit.

anaisbetts avatar anaisbetts commented on May 5, 2024

I'm not super excited about it, seems like a lot of added internal complexity. If I'm wrong though I'd take a PR!

from refit.

mburbea avatar mburbea commented on May 5, 2024

I think it can be resolved in the template generator. Simply assign a unique ordinal to each method by changing this line...

            ret.MethodList = interfaceTree.Members
                .OfType<MethodDeclarationSyntax>()
                .Select((x,i) => new MethodTemplateInfo() {
                    Name = x.Identifier.ValueText,
                    ReturnType = x.ReturnType.ToString(),
                    ArgumentList = String.Join(",", x.ParameterList.Parameters
                        .Select(y => y.Identifier.ValueText)),
                    ArgumentListWithTypes = String.Join(",", x.ParameterList.Parameters
                        .Select(y => String.Format("{0} {1}", y.Type.ToString(), y.Identifier.ValueText))),
                    IsRefitMethod = HasRefitHttpMethodAttribute(x),
                    MethodNumber = i,
                })

Something like that. Then Maybe switch to an array. And have each method stub lazily initialize itself. Or alternatively come up with a way to do the methodinfo reflection in a safe way. I don't know enough about the gimped TypeInfo version of reflection otherwise I might do it myself.
(Change the ToDictionary to a bunch of calls to Add passing in the appropriate ordinal.)

from refit.

nekresh avatar nekresh commented on May 5, 2024

I used something similar using mangled method names instead of method number.
It is still a Dictionary but I think it will be more readable and debug-able.

from refit.

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.