Fody / Ionad

Replaces static method calls.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ionad does not support method overloading

arontsang opened this issue · comments

Ionad always picks up the FIRST method overload with the correct name, and does not implement overloading resolution correctly.

In the below example we get an InvalidProgramException. But if you swap the order of declaration of the two overloads of TaskRx.Delay, the program runs.

    class Program
    {
        static async Task<int> Main(string[] args)
        {
            await Task.Delay(100000);
            return 0;
        }

    }

    [StaticReplacement(typeof(Task))]
    public static class TaskRx
    {

        public static Task Delay(int delay, CancellationToken cancellationToken)
        {
            return Observable.Timer(TimeSpan.FromMilliseconds(delay)).ToTask(cancellationToken);
        }

        public static Task Delay(int delay)
        {
            return Observable.Timer(TimeSpan.FromMilliseconds(delay)).ToTask();
        }
    }

Found the issue.

CecilExtensions:67 ReferenceMethod(this TypeReference typeRef, string methodName) is wrong. We also need to pass in the Parameter types.

I would create a PR to fix this code, but my company only allows RO access to Github.

@arontsang on the company note. based on this requirement https://github.com/Fody/Home/blob/master/pages/licensing-patron-faq.md#organization-licensing am i safe in assuming you are the only developer at your company?

@SimonCropp No I am not the only developer at my company.
I am trying to bring in Fody to our company, $3 per month per dev is not much at all...but conversely it could take time. We would be bringing in Fody to replace PostSharp.

I am paying out of pocket, which I don't mind for myself, partly because I have used Fody in the past for many project (I think before the patron thing started).

I've got a good handle on the bug itself, and I could try to put together a PR this weekend (assuming the home boss allows it).

PR raised.

#68

I would really appreciate it if you could also backport it to 1.0.2

Thank you

This is now deployed. NuGet may take some time to make it available for download.