question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VB -> C#: Add null if we have only space in function parameter

See original GitHub issue

Input code

Call mySuperFunction(strSomething, , optionalSomething)

Erroneous output

{
    ;
#error Cannot convert CallStatementSyntax - see comment for details
    /* Cannot convert CallStatementSyntax, CONVERSION ERROR: Conversion for OmittedArgument not implemented, please report this issue in '' at character 81
       at ICSharpCode.CodeConverter.CSharp.ExpressionNodeVisitor.DefaultVisit(SyntaxNode node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\ExpressionNodeVisitor.cs:line 82
       at ICSharpCode.CodeConverter.CSharp.CommentConvertingVisitorWrapper`1.Visit(SyntaxNode node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\CommentConvertingVisitorWrapper.cs:line 23
       at ICSharpCode.CodeConverter.CSharp.SyntaxNodeVisitorExtensions.AcceptAsync[T](SyntaxNode node, CommentConvertingVisitorWrapper`1 visitorWrapper) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\SyntaxNodeVisitorExtensions.cs:line 17
       at ICSharpCode.CodeConverter.CSharp.SyntaxNodeVisitorExtensions.<>c__DisplayClass4_0`2.<<AcceptAsync>b__0>d.MoveNext() in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\SyntaxNodeVisitorExtensions.cs:line 38
    --- End of stack trace from previous location where exception was thrown ---
       at ICSharpCode.CodeConverter.Shared.AsyncEnumerableTaskExtensions.SelectAsync[TArg,TResult](IEnumerable`1 source, Func`2 selector)
       at ICSharpCode.CodeConverter.CSharp.SyntaxNodeVisitorExtensions.AcceptAsync[TGeneral,TSpecific](IEnumerable`1 nodes, CommentConvertingVisitorWrapper`1 visitorWrapper) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\SyntaxNodeVisitorExtensions.cs:line 39
       at ICSharpCode.CodeConverter.CSharp.ExpressionNodeVisitor.<>c__DisplayClass66_0.<<VisitInvocationExpression>g__CreateElementAccess|1>d.MoveNext() in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\ExpressionNodeVisitor.cs:line 725
    --- End of stack trace from previous location where exception was thrown ---
       at ICSharpCode.CodeConverter.CSharp.ExpressionNodeVisitor.VisitInvocationExpression(InvocationExpressionSyntax node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\ExpressionNodeVisitor.cs:line 726
       at ICSharpCode.CodeConverter.CSharp.CommentConvertingVisitorWrapper`1.Visit(SyntaxNode node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\CommentConvertingVisitorWrapper.cs:line 23
       at ICSharpCode.CodeConverter.CSharp.SyntaxNodeVisitorExtensions.AcceptAsync[T](SyntaxNode node, CommentConvertingVisitorWrapper`1 visitorWrapper) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\SyntaxNodeVisitorExtensions.cs:line 17
       at ICSharpCode.CodeConverter.CSharp.MethodBodyExecutableStatementVisitor.VisitCallStatement(CallStatementSyntax node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\MethodBodyExecutableStatementVisitor.cs:line 744
       at ICSharpCode.CodeConverter.CSharp.ByRefParameterVisitor.CreateLocals(VisualBasicSyntaxNode node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\ByRefParameterVisitor.cs:line 53
       at ICSharpCode.CodeConverter.CSharp.ByRefParameterVisitor.AddLocalVariables(VisualBasicSyntaxNode node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\ByRefParameterVisitor.cs:line 49
       at ICSharpCode.CodeConverter.CSharp.CommentConvertingMethodBodyVisitor.ConvertWithTrivia(SyntaxNode node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\CommentConvertingMethodBodyVisitor.cs:line 44
       at ICSharpCode.CodeConverter.CSharp.CommentConvertingMethodBodyVisitor.DefaultVisit(SyntaxNode node) in D:\GitWorkspace\CodeConverter\ICSharpCode.CodeConverter\CSharp\CommentConvertingMethodBodyVisitor.cs:line 35

    Input:
    Call mySuperFunction(strSomething, , optionalSomething)

     */
}

Expected output

{
    mySuperFunction(strSomething, null, optionalSomething);
}

Details

  • Product in use: e.g. codeconverter.icsharpcode.net
  • Version in use: 7.3.0.0
  • Did you see it working in a previous version, which? No
  • Any other relevant information to the issue, or your interest in contributing a fix.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
Saibamencommented, Mar 14, 2020

@GrahamTheCoder This is not fixed. Try to convert this:

Dim strArtikelNummer As String
Dim strMengenEinheitAs String
Dim strKommentar As String

Function mySuperFunction(ArtikelNummer As String, MengenEinheit As String, Optional ist_die_Nummer_bereitsVorhanden As Boolean, Optional Kommentar As String)
End Function

Call mySuperFunction(strArtikelNummer, strMengenEinheit, , strKommentar)

Error:

Cannot convert CallStatementSyntax - see comment for details
/* Cannot convert CallStatementSyntax, System.InvalidCastException:
Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.EmptyStatementSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax'.
0reactions
Saibamencommented, Mar 31, 2020

Ah, ok 😉 The parameter in my code was optional string, not optional bool like in this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

vb.net - Empty string is not clear space character?
Try this method to check for blank strings. It is different from the Trim() versions in that it does not allocate a new...
Read more >
String.IsNullOrWhiteSpace(String) Method (System)
Indicates whether a specified string is null, empty, or consists only of white-space characters.
Read more >
String.IsNullOrEmpty(String) Method (System)
You can use the IsNullOrWhiteSpace method to test whether a string is null , its value is String.Empty, or it consists only of...
Read more >
How to check if a string has only whitespace or is empty in C#
The IsNullOrWhiteSpace () is used to indicate whether a specified string is empty, null , or contains only whitespace. Syntax. string.IsNullOrWhiteSpace(str) ...
Read more >
Strings of Zero Length Not Equivalent To NULL - Ask TOM
It seems that vb/asp doesn't handle NULL. It crashes if we assign NULL values to variables and try to do some string operation....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found