Skip to content

Commit 03b700b

Browse files
committed
C# type mapping fallback to GetSymbolInfo for type references
1 parent f307bf1 commit 03b700b

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

rewrite-csharp/csharp/OpenRewrite/CSharp/CSharpTypeMapping.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ public CSharpTypeMapping(SemanticModel model)
4343
{
4444
return MapType(typeInfo.Type);
4545
}
46+
47+
// For type references (e.g., in `new X()` or type constraints),
48+
// GetTypeInfo may return null. Fall back to GetSymbolInfo.
49+
var symbolInfo = _model.GetSymbolInfo(node);
50+
if (symbolInfo.Symbol is INamedTypeSymbol namedType)
51+
{
52+
return MapType(namedType);
53+
}
54+
4655
return null;
4756
}
4857

0 commit comments

Comments
 (0)