C
C#14mo 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
Pobiega14mo ago
so it can be chained
joeystdio
joeystdioOP14mo ago
of course 😄
Pobiega
Pobiega14mo ago
some people really like to do
services
.AddSomething()
.AddSomethingElse()
.AddAthirdThing();
services
.AddSomething()
.AddSomethingElse()
.AddAthirdThing();
(I'm one of those people)
joeystdio
joeystdioOP14mo ago
I never used chaining so didn't thought about that Yeah looks clean as well Thanks !
Tvde1
Tvde114mo ago
this is often called the "fluent" or "builder" pattern https://dzone.com/articles/fluent-builder-pattern
Pobiega
Pobiega14mo ago
it does break when you end up with the ones that return a specialized builder, like AddAuthorization etc
joeystdio
joeystdioOP14mo ago
Yes 🙂
Thinker
Thinker14mo ago
$close
MODiX
MODiX14mo ago
Use the /close command to mark a forum thread as answered
Pobiega
Pobiega14mo ago
he did, we juist re-opened it by writing 😄
Want results from more Discord servers?
Add your server