Please make Constructors DI Friendly #4156
Unanswered
TonyValenti
asked this question in
Language Ideas
Replies: 1 comment
-
Similar to requests to restrict the language, requests to generate purely additive code are very well suited to just using a Source-Generator. This would be a very easy one to write IMO. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Let's say you have a base class like so:
And you want to use a derived version of it.
Every time you derive from it you have to re-specify all of the constructors you want. For example:
This creates a lot of repetitive code and makes refactoring suck since adding a parameter to a base class requres that you refactor every single class that derives from it.
With regular methods, in a scenario like that, you only have to refactor explicit overrides.
I propose that if no constructors are specified on a class, that constructors be synthensized that match the parameters of the immediate base class.
Beta Was this translation helpful? Give feedback.
All reactions