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

Better handling of property injection #210

Open
Keboo opened this issue Feb 4, 2023 · 0 comments
Open

Better handling of property injection #210

Keboo opened this issue Feb 4, 2023 · 0 comments

Comments

@Keboo
Copy link
Owner

Keboo commented Feb 4, 2023

Consider the following

public class Foo
{
    [Dependency]
    public IService Service { get; set; }
}

It would be nice if this were weaved to be the equivalent of:

public class Foo
{
    private IService C<>_service;
    [Dependency]
    public IService Service 
    {
        get => C<>_service ?? GlobalDI.GetService<IService>();
        set => C<>_service = value;
    }
}

This would allow unit tests an opportunity to inject a test double without interfering with AutoDI functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant