A form of SetsRequiredMembers taking an array of member names #6567
Replies: 1 comment
-
I was searching for this feature and was very surprised to only find a all-or-nothing solution. In my case I tried to create a parent/child structure kind of like this:
As this obviously doesn't work I added a constructor to
Without If you have to explicitly mention each member you initialize in the constructor it also prevents bugs from later adding properties you don't initialize in this constructor. This pitfall is the reason I don't like the existing attribute The only real solution right now is to scrap
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Would the community see value in adding a new form of
SetsRequiredMembers
that takes an array of member names to suppress requiredness for?Sometimes there are (optional) properties that set one or multiple required properties. Ideally having an attribute on the optional property and setting it should be enough to fulfill the required contract.
A good example is where you're dealing with ranges and you want a shorthand, there are probably other good examples.
Beta Was this translation helpful? Give feedback.
All reactions