How to debug a factory func injected via a class constructor using DryIoc

25 views Asked by At

I've been converting a Prism 6 application to Prism 8, and had to swap out Prism.Autofac in the process. I selected Prism.DryIoc as it's substitute and have largely been able to switch over just fine, however some viewmodels accepted a wrapped Func<TIn, TOut> where TIn is a class the viewmodel works with and TOut is another. The wrapper implemented some simple dispose behaviour to prevent it being invoked after being disposed. We used the Autofac Owned<> concept but with that being removed I have converted references to this wrapper to a normal Func. When using Autofac (as the wrapped func) this was ran fine, some reactiveUI code would use this when some property was set to generate some UI, however in DryIoc, while the DisposableFunc resolves and is assigned, it doesn't seem to run correctly and it's inner func, while also assigned, can't be stepped into as before, and returns null.

I have tried simplifying these to normal Funcs as I have said, but see the same behaviour

The relevant parts of the view model looks something like this:

public SomeClass(
    ISomeService someService,
    Func<SomeInput1, SomeInput2, SomeOutput> createOutput)
{
    this.outputs = ObservableAsPropertyHelper<ImmutableList<SomeOutput>>.Default();

    this.WhenActivated(disposables =>
    {
        this.outputs = this.WhenAnyValue(
            x => x.SomeInput1Source,
            x => x.SomeInput2Source,
            (input1, input2) => new { input1, input2})
            .SelectLatestFromAsync(x => this.someService.TryGetSomeOutputAsync(x.input1, x.input2))
            .Select(x => x.Select(ev => createOutput.Invoke(null, ev)).Where(n => n != null).ToImmutableList())
            .ToProperty(this, x => x.Outputs)
            .DisposeWith(disposables);
    }
}

The inputs and outputs are not registered, this didn't cause a problem with Autofac and I haven't disabled dynamically creating concrete types in the container config, and there are no exceptions or warnings when initialising the container or these viewmodels. I'm not sure what I might be missing?

0

There are 0 answers