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

Use SplatRegistrations.Register with Generic #137

Open
mysteryx93 opened this issue Jul 30, 2022 · 3 comments
Open

Use SplatRegistrations.Register with Generic #137

mysteryx93 opened this issue Jul 30, 2022 · 3 comments

Comments

@mysteryx93
Copy link

mysteryx93 commented Jul 30, 2022

Is it possible to use SplatRegistrations like this?

It says:

ViewModelLocator.cs(64, 9): [SPLATDI001] TConcrete has more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute
public static void RegisterWithDesign<TInterface, TDesign>(this IMutableDependencyResolver resolver)
    where TDesign : TInterface, new() => RegisterWithDesign<TInterface, TInterface, TDesign>(resolver);

public static void RegisterWithDesign<TInterface, TConcrete, TDesign>(this IMutableDependencyResolver resolver)
    where TDesign : TInterface, new()
{
    SplatRegistrations.Register<TInterface, TConcrete>("Init");
    resolver.Register<TInterface>(() =>
        Design.IsDesignMode ? new TDesign() : Locator.Current.GetService<TInterface>("Init"));
}

If not; it could be a neat feature to add.

@mysteryx93
Copy link
Author

Even this is not currently working. That's a big problem.

SplatRegistrations.Register<IAppUpdateService, AppUpdateService<TSettings>>();

@glennawatson
Copy link
Contributor

Be likely a change needed in the Roslyn scanning.

I'm not going to get to making this change for a little while if you get on slack at some point I could help you with the code to provide a PR.

@AlienJust
Copy link

AlienJust commented Dec 7, 2022

Even this is not currently working. That's a big problem.

Hi, how do You think, is this behavior could be related: reactiveui/ReactiveUI#3440 ?

GitHub
Hi, I'm writing Avalonia desktop app and I have VM that looks like: public class SampleViewModel<T> : ReactiveObject, IRoutableViewModel, ISampleViewModel {...} interface ISampleViewModel...

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

3 participants