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

Required Properties support by default #563

Open
dadhi opened this issue Mar 16, 2023 Discussed in #562 · 7 comments
Open

Required Properties support by default #563

dadhi opened this issue Mar 16, 2023 Discussed in #562 · 7 comments
Assignees
Labels
documentation enhancement New feature or request
Milestone

Comments

@dadhi
Copy link
Owner

dadhi commented Mar 16, 2023

Discussed in #562

Originally posted by TonyValenti March 16, 2023
AutoFac recently implemented required properties injection and it is awesome!

https://autofac.readthedocs.io/en/latest/register/prop-method-injection.html#required-properties

This eliminates a ton of boilerplate constructor code, especially where inheritance is involved.

Dryloc should follow suit.

@dadhi dadhi self-assigned this Mar 16, 2023
@dadhi dadhi added this to the v6.0.0 milestone Mar 16, 2023
@dadhi dadhi added enhancement New feature or request documentation labels Mar 16, 2023
@TonyValenti
Copy link

Also, just so you know, AutoFac looks at the attributes that C# decorates classes and properties with so that no extra properties or attributes are necessary. It doesn't set all properties. Just the required ones which is really nice.

@dadhi
Copy link
Owner Author

dadhi commented Mar 22, 2023

@TonyValenti got it

@TonyValenti
Copy link

Any idea when this will be released?

dadhi added a commit that referenced this issue Apr 14, 2023
…g constuctor when injecting the properties for #563
dadhi added a commit that referenced this issue Apr 17, 2023
@dadhi dadhi modified the milestones: v6.0.0, v5.4.0 Apr 17, 2023
@dadhi
Copy link
Owner Author

dadhi commented Apr 17, 2023

Here is the example how to configure the required properties support for DryIoc v5.4.0 (currently in preview)

@TonyValenti
Copy link

Hi @dadhi ,
Would you consider making required properties on by default? It would be really great if Dryloc was compatible with Autofac in this way so that folks could simply adopt it and it just work. Also, if it was on by default, it would allow you to promote additional lines of code saved because all the overhead of constructor chaining then goes away automatically.

dadhi added a commit that referenced this issue Apr 18, 2023
dadhi added a commit that referenced this issue Apr 18, 2023
@dadhi
Copy link
Owner Author

dadhi commented Apr 30, 2023

@TonyValenti For the next version v5.4.0 you need to specify the support for the required properties via:

var c = new Container(rules => rules.With(propertiesAndFields: PropertiesAndFields.RequiredProperties()));

I still need to work out the performance considerations to make it the default rule.
So it will go either into v5.5.0 or to v6.0.0

@dadhi dadhi changed the title Required Properties support Required Properties supportby default Apr 30, 2023
@dadhi dadhi changed the title Required Properties supportby default Required Properties support by default Apr 30, 2023
@dadhi
Copy link
Owner Author

dadhi commented Apr 30, 2023

The issue for the custom rule support #571

@dadhi dadhi modified the milestones: v5.4.0, v6.0.0 Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants