Skip to content

Conversation

Nonanti
Copy link

@Nonanti Nonanti commented Sep 9, 2025

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.

Resolves an issue where OverriddenMethod could be null during semantic
classification in Visual Studio, causing a StreamJsonRpc.RemoteInvocationException.

The fix simplifies the while loop condition to check for both IsOverride
and OverriddenMethod != null in a single expression, preventing the null
reference exception.

Fixes dotnet#59736
@github-actions github-actions bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Sep 9, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Sep 9, 2025
Copy link
Contributor

Thanks for your PR, @@Nonanti. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@martincostello martincostello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates analyzer Indicates an issue which is related to analyzer experience and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer Indicates an issue which is related to analyzer experience area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Semantic classification is currently unavailable due to an internal error
2 participants