Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Highlighted
dcarlstedt
Visitor.
790 views

Translating .Net Core Web Applications

I'm having issues getting successful translations to complete without errors for my .net core web applications. The errors that I"m seeing are all related to the translator not being able to translate foreach loops within our code.

Code that will trigger the error

 

int[] values = new int[] { 1,2,3,4 };
foreach (int v in values)
{
     // code here
}

Translation Error

 

 

[warning]: Translation errors occurred during execution of .Net translator: Failed to translate method GetHeaderAndBase64Decode at C:\git\WebAPI\Source\Application.WebAPI\Controllers\DiagnosticsController.cs:167:8
SCA.TranslationException: Failed to resolve GetLength method call for array-type expression in foreach loop at C:\git\WebAPI\Source\Application.WebAPI\Controllers\DiagnosticsController.cs:183:34
   at SCA.CSharpTranslator.VisitForEachStatement(ForEachStatementSyntax node) in C:\TenaciousD_Comp\sca\src\net\roslyn-translator\translator\src\csharp.cs:line 3438
   at SCA.CSharpTranslator.VisitBlock(BlockSyntax node) in C:\TenaciousD_Comp\sca\src\net\roslyn-translator\translator\src\csharp.cs:line 121
   at SCA.CSharpTranslator.VisitTryStatement(TryStatementSyntax syntax) in C:\TenaciousD_Comp\sca\src\net\roslyn-translator\translator\src\csharp.cs:line 483
   at SCA.CSharpTranslator.VisitBlock(BlockSyntax node) in C:\TenaciousD_Comp\sca\src\net\roslyn-translator\translator\src\csharp.cs:line 121
   at SCA.CSharpTranslator.translateMethodBody(CSharpSyntaxNode node, STFunDecl function, IMethodSymbol method, Boolean isStatic, ArrowExpressionClauseSyntax exprBody) in C:\TenaciousD_Comp\sca\src\net\roslyn-translator\translator\src\csharp.cs:line 4457

If I change out the foreach loop into a for loop the translation error is fixed, however that is not ideal.

 

Here are the parameters I'm sending to sourceanalyzer to perform the translation which happens after I build (DEBUG) and restore packages:

  • -dotnet-core-version 2.1
  • -aspnetcore
  • libdirs **/* **/*

Here is what I've tried to resolve this:

  • changing -dotnet-core-version to the runtime version I'm using which is 2.1.8
  • changing -dotnet-core-version to the sdk version I'm using which is 2.1.50

The command I'm running

sourceanalyzer.exe -b 123 -verbose -debug -logfile sca_binaries_logfile.txt -aspnetcore -dotnet-core-version 2.1 -libdirs **/* **/*

My questions:

  • How can I fix these translation errors?
  • Where's the documentation specifying which version numbers are accepted for -dotnet-core-version, -dotnet-standard-version
  • Do you see anything wrong with what I'm doing on the command line when calling source analyzer?

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.