C# 11 required property support
See original GitHub issueNow that C# 11 has required properties, are there plans for SimpleInjector to support auto-injecting those?
Issue Analytics
- State:
- Created 8 months ago
- Comments:14
Top Results From Across the Web
required modifier - C# Reference
The required modifier is available beginning with C# 11. The required modifier enables developers to create types where properties or fields ...
Read more >Introducing C#11: Required properties
C# 11 improves the initialization of objects and struct. Marking one or more properties as mandatory on initialization is now possible and will ......
Read more >Introducing the C# 11 Required Keyword - The New Dev's Guide
Unlike past solutions, the required keyword makes the compiler responsible for enforcing setting of non-nullable properties. This ultimately ...
Read more >C# 11 required members
C# 11 proposes the new keyword required that can apply to an instance property or an instance field declaration within a class ,...
Read more >The Required Keyword in C# 11
The required keyword fixes object initializers and can potentially change how you implement classes in C#. · When working with Nullable Reference ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

SimpleInjector has always been about writing clean code. I always feel like a journey back in time, when I have to use the “new” Microsoft Dependency Injection.
There are sometimes reasons to use property injection. I used basically the same code I posted before with my own DependencyAttribute (the required keyword did not exist at that time) in project with a lot of legacy code heavily using inheritance.
Perhaps a compromise would be to have a fitting PropertySelectionBehavior included and a nice extension method or boolean property in the options to activate it?
Generally speaking yes of course, but not always possible or desirable when working with view models in MVVM desktop scenarios.