✅ Options pattern - why have a separate XOptions type?
Assuming my "options type" has no intent of being used outside of configuring
GitHubLfsAuthenticator
.
What I'm currently doing, completely without the Options pattern, is this via an extension method:
However, I feel like a user who wanted to do something other than this might be confused, so I thought maybe the Options pattern was the solution, but it doesn't really seem to provide any benefit over what I have now.10 Replies
the
Microsoft.Extensions.Options
libarary offers more functionality than just pull options from DI
most notably, it offers a system of change notification
although, I will readily admit that the last time I looked into it, it was confusing
I don't fully remember why
something to do with mutability/immutability?
if you haven't definitely give this a readOptions pattern - .NET
Learn the options pattern to represent groups of related settings in .NET apps. The options pattern uses classes to provide strongly-typed access to settings.
it offers some other points regarding this same question
oooh, "named options" is another big one
This sounds extremely overengineered for what I'm aiming for here...but then again, who am I to tell users how they can and cant configure the service, I guess
definitely don't use it if you don't think it's useful
re-reading, I realize now you weren't asking about this library, specifically
so.... yeah
but the article's still a good read, the problems it talks about that are solved by the library are the same kinda problems you might care about
I don't like "not using things" because I don't understand them, but I also don't like imposing confusing or overkill things on end-users 😅
I'll give it a read for sure
it also might be a good idea to use that library, if your intention is that users will be using this within ASP.NET
it'll definitely make for less setup
There will be a hosting option for it with ASP.NET, but also for those without, at least in the future
alternatively, you could keep it minimal in your library, and publish a second package that provides extensions for using your lib, under the Microsoft umbrella
I'm starting with asp.net and branching out into others as people say "hey I want to host this on [x]"