Skip to content

Commit 4abccdb

Browse files
Guard against nullref
1 parent 186cfd5 commit 4abccdb

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

CodeConverter/VB/CommonConversions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ private VariableDeclaratorSyntax ConvertToVariableDeclarator(CSS.DeclarationExpr
147147
var ids = SyntaxFactory.SingletonSeparatedList(SyntaxFactory.ModifiedIdentifier(id));
148148
TypeSyntax typeSyntax;
149149
if (des.Type.IsVar) {
150-
var typeSymbol = ModelExtensions.GetSymbolInfo(_semanticModel, des.Type).ExtractBestMatch<ITypeSymbol>();
151-
typeSyntax =(TypeSyntax) VbSyntaxGenerator.TypeExpression(typeSymbol);
150+
typeSyntax = ModelExtensions.GetSymbolInfo(_semanticModel, des.Type).ExtractBestMatch<ITypeSymbol>() is { } typeSymbol
151+
? (TypeSyntax) VbSyntaxGenerator.TypeExpression(typeSymbol)
152+
: null;
152153
} else {
153154
typeSyntax = (TypeSyntax)des.Type.Accept(_nodesVisitor);
154155
}

0 commit comments

Comments
 (0)