Git Product home page Git Product logo

Comments (7)

 avatar commented on August 21, 2024

Looks like it's might be due to the shimsham class using a dictionary to store the method infos. If the key is just the method name, I'm suspecting it might be dropping any overloads, leaving room for just one.

image

from peanutbutter.

fluffynuts avatar fluffynuts commented on August 21, 2024

fascinating! I wasn't aware anyone else was actually using this!

any ideas for a fix? PRs are appreciated (:

from peanutbutter.

fluffynuts avatar fluffynuts commented on August 21, 2024

I'd probably start by modifying the lookup to use a key of tuple: (string: Type[]) so that the correct overload can be selected (or to be an IDictionary<string, MethodInfo> and select the correct one lazily - this might be slower if it's hot code, but probably provides the most flexibility

you're certainly using this beyond the original scope, but that's pretty cool (:

from peanutbutter.

fluffynuts avatar fluffynuts commented on August 21, 2024

I must admit that I rarely use this for method ducking - but I use this a lot for property ducking, especially off to dictionaries and NameValueCollections, so I'm quite pleased that someone else is (a) finding it useful and (b) pushing boundaries

from peanutbutter.

fluffynuts avatar fluffynuts commented on August 21, 2024

@aracicot-fusebill please check out package 3.0.10 - I've implemented overloads and also improved the fuzzy ducker for the case where the interface method and the ducked type have the same parameters, just in different orders, based on type - this won't re-order according to name, ie if we have:

// concrete type
public class Worker
{
  public void DoWork(string str, int a)
  {
  }
}

// ducked interface
public interface IMyWorker
{
  void DoWork(int a, string foo)
  {
  }
}

then we can do worker.FuzzyDuckAs<IMyWorker>() and expect DoWork to work appropriately, but if we have

public class Stringy
{
  public void DoWork(string first, string second)
  {
  }
}

// ducked interface
public interface IMyStringy
{
  void DoWork(string second, string first);
}

then we can DuckAs<IMyWorker>() but the order of parameters will not be switched in the call

from peanutbutter.

fluffynuts avatar fluffynuts commented on August 21, 2024

@aracicot-fusebill have you had a chance to check out the latest package & see if it does what you're expecting?

from peanutbutter.

fluffynuts avatar fluffynuts commented on August 21, 2024

@aracicot-fusebill closing as I believe I've sorted this out; please re-open if need be.

from peanutbutter.

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.