Fix null reference exception in MvcFacts.GetDeclaringType
Description
Fixed a null reference exception that occurs during semantic classification in Visual Studio when analyzing overridden methods.
Issue
Fixes #59736
Changes
- Modified the while loop condition in
GetDeclaringTypemethod to check bothIsOverrideandOverriddenMethod != nulltogether - This prevents accessing a potentially null
OverriddenMethodproperty
Technical Details
The original code would enter the loop when method.IsOverride was true, but OverriddenMethod could still be null in certain edge cases. By combining both checks in the loop condition, we avoid the null reference exception entirely.
Testing
Built the project locally and verified the change resolves the issue without breaking existing functionality.
Thanks for your PR, @@Nonanti. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.
/azp run
Commenter does not have sufficient privileges for PR 63593 in repo dotnet/aspnetcore
/azp run
Commenter does not have sufficient privileges for PR 63593 in repo dotnet/aspnetcore