Skip to content

Wrong decorator parameter with custom args #672

@QianMoXi

Description

@QianMoXi

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions