File tree Expand file tree Collapse file tree
ICSharpCode.CodeConverter/CSharp Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ private TypeConversionKind AnalyzeConversion(Microsoft.CodeAnalysis.VisualBasic.
105105 }
106106 return TypeConversionKind . Implicit ;
107107 }
108+ else if ( csConversion . IsExplicit && csConversion . IsEnumeration )
109+ {
110+ return TypeConversionKind . Implicit ;
111+ }
108112 else if ( csConversion . IsExplicit && vbConversion . IsNumeric && vbType . TypeKind != TypeKind . Enum )
109113 {
110114 return TypeConversionKind . Explicit ;
Original file line number Diff line number Diff 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 }
@@ -397,6 +407,34 @@ public void Bar(int x)
397407}" ) ;
398408 }
399409
410+ [ Fact ]
411+ public void IntToEnumArg ( )
412+ {
413+ TestConversionVisualBasicToCSharpWithoutComments ( @"Public Class Class1
414+ Sub Foo(ByVal arg As TriState)
415+ End Sub
416+
417+ Sub Main()
418+ Foo(0)
419+ End Sub
420+ End Class" ,
421+ @"using Microsoft.VisualBasic;
422+
423+ public class Class1
424+ {
425+ public void Foo(TriState arg)
426+ {
427+ }
428+
429+ public void Main()
430+ {
431+ Foo((TriState)0);
432+ }
433+ }" ) ;
434+ }
435+
436+
437+
400438 [ Fact ]
401439 public void EnumSwitch ( )
402440 {
You can’t perform that action at this time.
0 commit comments