[release/8.0-rc2] Ensure Bind can handle null from GetSection by github-actions[bot] · Pull Request #92477 · dotnet/runtime (original) (raw)
Backport of #92384 to release/8.0-rc2
/cc @ericstj
Customer Impact
NullReferenceException when an IConfiguration instance returns null from GetSection. No implementations in the product do this, and the interface is not annotated to return null, however we received a customer report of this regression from mocking the interface. When using moq to mock an interface it will return null for unspecified cases.
Testing
Tested customer reported case manually using Moq. Added automated test for both runtime binder and source gen to catch this behavior.
Risk
Very low - we are only adding back a null check that was removed from a previous change in RC2.