Closed vzam closed 4 months ago
That's an excellent idea! I also very much like your naming for the proposed attributes. Interestingly, FluentContinueWith
also allows for loops and optional steps. An API like this
int hashCode = CreateHashCode
.Add(42).Add(3.14).AddSequence(new[] { 1, 2, 3 }).Add("Hello world").Value();
could be realized by specifying step 0 for all methods and applying [FluentContinueWith(0)]
to all methods except the Value
method.
I plan to implement this soon. Thanks!
As I understand it, the options to every step have to be provided and you cannot skip steps in between for a single path:
In this example I would like to skip step 1 entirely after having selected
UseOtherThing()
at step 0, maybe with a new attribute[FluentSkipTo(2)]
or[FluentContinueWith(2)]
, also it might be considered to have[FluentBreak]
to finalize the object if the last steps are no longer relevant for the chosen configuration. This can be generated as follows:I think this is a fairy common pattern and would benefit the library.