C
C#15mo ago
joeystdio

✅ Why return IServiceCollection in an extension method?

Is there any reason why not to make the method void instead?
No description
10 Replies
Pobiega
Pobiega15mo ago
so it can be chained
joeystdio
joeystdioOP15mo ago
of course 😄
Pobiega
Pobiega15mo ago
some people really like to do
services
.AddSomething()
.AddSomethingElse()
.AddAthirdThing();
services
.AddSomething()
.AddSomethingElse()
.AddAthirdThing();
(I'm one of those people)
joeystdio
joeystdioOP15mo ago
I never used chaining so didn't thought about that Yeah looks clean as well Thanks !
Tvde1
Tvde115mo ago
this is often called the "fluent" or "builder" pattern https://dzone.com/articles/fluent-builder-pattern
Pobiega
Pobiega15mo ago
it does break when you end up with the ones that return a specialized builder, like AddAuthorization etc
joeystdio
joeystdioOP15mo ago
Yes 🙂
Thinker
Thinker15mo ago
$close
MODiX
MODiX15mo ago
Use the /close command to mark a forum thread as answered
Pobiega
Pobiega15mo ago
he did, we juist re-opened it by writing 😄
Want results from more Discord servers?
Add your server