File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed
ICSharpCode.CodeConverter/CSharp Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -762,7 +762,7 @@ public override CSharpSyntaxNode VisitDeclareStatement(VBSyntax.DeclareStatement
762762 var attributeLists = ConvertAttributes ( node . AttributeLists ) . Add ( dllImportAttributeList ) ;
763763
764764 var modifiers = CommonConversions . ConvertModifiers ( node . Modifiers ) . Add ( SyntaxFactory . Token ( SyntaxKind . StaticKeyword ) ) . Add ( SyntaxFactory . Token ( SyntaxKind . ExternKeyword ) ) ;
765- var returnType = ( TypeSyntax ) node . AsClause ? . Type . Accept ( TriviaConvertingVisitor ) ;
765+ var returnType = ( TypeSyntax ) node . AsClause ? . Type . Accept ( TriviaConvertingVisitor ) ?? SyntaxFactory . ParseTypeName ( "void" ) ;
766766 var parameterListSyntax = ( ParameterListSyntax ) node . ParameterList ? . Accept ( TriviaConvertingVisitor ) ??
767767 SyntaxFactory . ParameterList ( ) ;
768768
Original file line number Diff line number Diff line change @@ -550,14 +550,16 @@ private void TestMethod()
550550}" ) ;
551551 }
552552
553- [ Fact ]
554- public void DeclareStatement ( )
553+ [ Theory ]
554+ [ InlineData ( "Sub" , "" , "void" ) ]
555+ [ InlineData ( "Function" , " As Long" , "long" ) ]
556+ public void DeclareStatement ( string vbMethodDecl , string vbType , string csType )
555557 {
556558 // Intentionally uses a type name with a different casing as the loop variable, i.e. "process" to test name resolution
557- TestConversionVisualBasicToCSharp ( @"Imports System.Diagnostics
559+ TestConversionVisualBasicToCSharp ( $ @ "Imports System.Diagnostics
558560
559561Public Class AcmeClass
560- Private Declare Function SetForegroundWindow Lib ""user32"" (ByVal hwnd As Int32) As Long
562+ Private Declare { vbMethodDecl } SetForegroundWindow Lib ""user32"" (ByVal hwnd As Int32){ vbType }
561563
562564 Public Shared Sub Main()
563565 For Each process In Process.GetProcesses().Where(Function(p) Not String.IsNullOrEmpty(p.MainWindowTitle))
@@ -566,24 +568,24 @@ For Each process In Process.GetProcesses().Where(Function(p) Not String.IsNullOr
566568 Next
567569 End Sub
568570End Class"
569- , @"using System;
571+ , $ @ "using System;
570572using System.Diagnostics;
571573using System.Linq;
572574
573575public class AcmeClass
574- {
576+ {{
575577 [System.Runtime.InteropServices.DllImport(""user32"")]
576- private static extern long SetForegroundWindow(Int32 hwnd);
578+ private static extern { csType } SetForegroundWindow(Int32 hwnd);
577579
578580 public static void Main()
579- {
581+ {{
580582 foreach (var process in Process.GetProcesses().Where(p => !string.IsNullOrEmpty(p.MainWindowTitle)))
581- {
583+ {{
582584 SetForegroundWindow(process.MainWindowHandle.ToInt32());
583585 Thread.Sleep(1000);
584- }
585- }
586- }" ) ;
586+ }}
587+ }}
588+ }} " ) ;
587589 }
588590
589591 [ Fact ]
You can’t perform that action at this time.
0 commit comments