From 1399ba68e9ae5b6ba672f0b956343d6c62a32c4f Mon Sep 17 00:00:00 2001 From: Nonantiy <45326482+Nonanti@users.noreply.github.com> Date: Tue, 9 Sep 2025 03:08:18 +0300 Subject: [PATCH] Fix null reference exception in MvcFacts.GetDeclaringType 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 #59736 --- src/Shared/Roslyn/MvcFacts.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Shared/Roslyn/MvcFacts.cs b/src/Shared/Roslyn/MvcFacts.cs index d4c74f64fb78..772b60fd83c4 100644 --- a/src/Shared/Roslyn/MvcFacts.cs +++ b/src/Shared/Roslyn/MvcFacts.cs @@ -101,13 +101,8 @@ public static bool IsControllerAction(IMethodSymbol method, INamedTypeSymbol non private static INamedTypeSymbol? GetDeclaringType(IMethodSymbol method) { - while (method.IsOverride) + while (method.IsOverride && method.OverriddenMethod != null) { - if (method.OverriddenMethod == null) - { - return null; - } - method = method.OverriddenMethod; }