OptionsMonitor<T>.Current is not a field, it invokes a get on ConcurrentDictionary. In some codebases this can be used a lot. Sure, caching the current value is possible but the API surface doesn't make it obvious that it should be done.
I understand it's for simplicity allowing the same codepath to be used for named Config values as well as the default named string.Empty (which this property getter accesses) but it might be worth it to special case for the most common scenario and cache current value in a normal field so that access is essentially free (and inlinable and all that).
OptionsMonitor<T>.Current
is not a field, it invokes a get onConcurrentDictionary
. In some codebases this can be used a lot. Sure, caching the current value is possible but the API surface doesn't make it obvious that it should be done.I understand it's for simplicity allowing the same codepath to be used for named Config values as well as the default named
string.Empty
(which this property getter accesses) but it might be worth it to special case for the most common scenario and cache current value in a normal field so that access is essentially free (and inlinable and all that).