aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Fix null reference exception in MvcFacts.GetDeclaringType

Open Nonanti opened this issue 4 months ago • 6 comments

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 GetDeclaringType method to check both IsOverride and OverriddenMethod != null together
  • This prevents accessing a potentially null OverriddenMethod property

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.

Nonanti avatar Sep 09 '25 00:09 Nonanti

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

Nonanti avatar Sep 16 '25 20:09 Nonanti

Commenter does not have sufficient privileges for PR 63593 in repo dotnet/aspnetcore

azure-pipelines[bot] avatar Sep 16 '25 20:09 azure-pipelines[bot]

/azp run

Nonanti avatar Sep 16 '25 20:09 Nonanti

Commenter does not have sufficient privileges for PR 63593 in repo dotnet/aspnetcore

azure-pipelines[bot] avatar Sep 16 '25 20:09 azure-pipelines[bot]