One of the code samples access the value of an IOptionsMonitor<T>:
sp.GetRequiredService<IOptionsMonitor<AnnotatedOptions>>().Value);
Since Value doesn't exist, should this be CurrentValue?
.Value access in other related samples may also be affected.
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hello @jawn ... yes ... that must go all the way back to when we wrote the topic because it's also the case in a 2.x app (or perhaps it changed at 2.1-2.2 and we missed it on those updates).
I'll fix that up. Thanks for letting us know. I also see another little nit WRT the App metapackage. That sentence should be removed/changed in the >=3.0 version, so I'll square that away at the same time.
Looks like IOptionsMonitor with CurrentValue was a 2.2 bit, so that's where it went wrong ... when it was added for the 2.2 release.
Thanks. In an ideal world, all code samples would be compiled against the .NET Core version they apply to.
"Ideal" being the key word there. There are just a few of us here working FT at any given time on >300 topics, >100 samples, and >500 GH issues ... you get the picture. 🏃😅
We usually catch something like this in review because the engineers have very good eyes :eyes: for our little doc code slip-ups. This is an example that isn't part of the sample app; therefore, it's only in the text of the doc. It was never compiled for any version as a text-only example.
I went back and looked at https://github.com/aspnet/AspNetCore.Docs/issues/9662 and https://github.com/aspnet/AspNetCore.Docs/pull/9684 ... we did a thing here where we went from IOptions to IOptionsMonitor as the preferred/recommended approach. IOptions _does_ have a Value. It was a blown update when it went to IOptionsMonitor.
Anyway ... excuses ... excuses ... Yuck! :smile: You caught it, and we'll get it fixed up. The community has made _major_ contributions in catching these things and reporting them to us. With any luck, we'll have this updated by the end of day. It must not have been a major hang-up tho ... it's been wrong for almost a year! 🙈 lol
No problem, I appreciate the work and quick responses.