Skip to content

Commit f198470

Browse files
committed
Fix ByRef Nothing parameters
1 parent 91867c2 commit f198470

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

ICSharpCode.CodeConverter/CSharp/NodesVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ private bool NeedsVariableForArgument(VBSyntax.SimpleArgumentSyntax node)
14741474
bool isUsing = symbolInfo?.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax()?.Parent?.Parent?.IsKind(VBasic.SyntaxKind.UsingStatement) == true;
14751475

14761476
var typeInfo = _semanticModel.GetTypeInfo(node.Expression);
1477-
bool isTypeMismatch = !typeInfo.Type.Equals(typeInfo.ConvertedType);
1477+
bool isTypeMismatch = typeInfo.Type == null || !typeInfo.Type.Equals(typeInfo.ConvertedType);
14781478

14791479
return (!isIdentifier && !isMemberAccess) || isProperty || isTypeMismatch || isUsing;
14801480
}

Tests/CSharp/ExpressionTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ ElseIf Bar(True = False) Then
230230
End If
231231
End Sub
232232
233+
Sub Foo5()
234+
Bar(Nothing)
235+
End Sub
236+
233237
Sub Bar(ByRef b As Boolean)
234238
End Sub
235239
@@ -290,6 +294,12 @@ public void Foo4()
290294
}
291295
}
292296
297+
public void Foo5()
298+
{
299+
var argb = default(bool);
300+
Bar(ref argb);
301+
}
302+
293303
public void Bar(ref bool b)
294304
{
295305
}

0 commit comments

Comments
 (0)