Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong decorator parameter with custom args #672

Open
QianMoXi opened this issue Dec 4, 2024 · 1 comment
Open

Wrong decorator parameter with custom args #672

QianMoXi opened this issue Dec 4, 2024 · 1 comment

Comments

@QianMoXi
Copy link

QianMoXi commented Dec 4, 2024

Steps:

  1. Create one Console App (net 8)
  2. Add Packages:
<PackageReference Include="DryIoc.dll" Version="5.4.3" />
  1. Code:
public abstract class A;
public class A1 : A;

internal class Program
{
    static void Main(string[] args)
    {
        var container = new Container();

        container.Register<object, A1>(serviceKey: "A1");

        var decorateMethod = typeof(Program).SingleMethod(nameof(DecoratorA), true);

        container.Register<object>(made: Made.Of(r => decorateMethod),
                                            setup: Setup.DecoratorOf<A>());

        var res = container.Resolve<object>("A1", args: [ DateTime.Now ]);

        //res is DateTime
    }

    private static object DecoratorA(object t)
    {
        //t is DateTime

        return t;
    }
}

Why is the parameter t of the incoming method DecoratorA in this case of type DateTime?

The above code may seem strange, but in Prism, the View is registered as object, so here's an example of the easiest way to reproduce it.

@dadhi
Copy link
Owner

dadhi commented Dec 4, 2024

@QianMoXi Thanks for submitting. I will check.

dadhi added a commit that referenced this issue Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants