Upgrading to AlterNet libraries - trouble with Roslyn Parser

Hi,
I'm currently in the process of upgrading our Script Editor from QWhale to AlterNet. This worked pretty easy as I only needed to change Dlls and namesspaces. We use the Script Editor and Parser to allow our users to extend our product with a kind of JIT-compiled plugins in C# or VB.net. The user is presented with a CodeDom generated template class which derives from generated bass class. This base class is not visible to the user. Additionally some classes from our Kernel assemblies are made accessible. The resulting source code is compiled with Roslyn compiler.
During the upgrade process I started to use ''Roslyn.CsParser" but stumbled upon some problems. E.g. I could not register certain types to the parser. Neither was it possible for me to register the source of the hidden base class.
My questions:
Is it possible to use the Roslyn.CsParser like the Advanced.CsParser (which works for me except that it has a few problems with C# 7.0 syntax)?
Is the Advanced.CsParser considered as fully C# 7.0 compatible?
Do you have any tips for the migration from QWhale to AlterNet?
Best Regards
Karol
Hi Karol,
As C# Advanced parser supports most of 7.0 features, could you please elaborate on the problems with it you've mentioned?
Roslyn-based parser certainly provides more accurate syntax analysis and other features like code completion, diagnostic, etc.
However you can't register single (or list of) types for its code completion, the code completion engine operates on per-assembly basis, so you would need to register whole assembly, which will enable using all types from it.
(this can be done by using parser.Repository.RegisterAssembly method)
You can also register source code of the hidden class to the parser with the following code:
parser.Repository.AddDocument(fileName, text);
Let me know if it helps.
Dmitry
Hi Dmitry,
thanks for the quick reply.
Following code examples show errors with the Advanced.CsParser:

public static class Rnd
{
static Random r = null;
static Rnd()
{
r = new Random(1);
}
public static float Random(float min, float max)
{
return (float) r.Next((int) (min * 10), (int) (max * 10)) / 10.0f;
}
}

Errors reported:
Line 18, Column 61: Semicolon expected
Line 18, Column 61: Syntax Error
Line 18, Column 63: Semicolon expected

public class Point
{
public double X { get; }
public double Y { get; }
public Point(double x, double y) => (X, Y) = (x, y);
}

Errors reported:
Line 15, Column 40: Identifier_Literal expected
Line 15, Column 43: Syntax Error
Line 15, Column 40: Identifier_Literal expected
...
Line 15, Column 40: Close_parens expected
Line 15, Column 40: Semicolon expected

Best Regards
Karol
Hi Karol,
Thank you for providing these examples.
The first problem was introduced when we added support for tuples. It seems to happen only in return statement.
This works for example.
public static float Random(float min, float max)
{
var x = (float) r.Next((int) (min * 10), (int) (max * 10)) / 10.0f;
return x;
}
and should be quite easy to fix, and we're happy to send you a hot fix once we test it.
Second issue seems to be related to parsing lamba expressions, with this one we will need to do a bit more investigations.
Regards,
Dmitry
Hi Dmitry,
I found a further problem: @ at the beginning of a member name is not accepted:
private int @__m_Int1;
Best Regards
Karol
Hi Karol,
Thank you for reporting this issue, it will be trivial to fix.
I will let you know once we fix other issues as well.
Regards,
Dmitry
Hi Karol,
These errors should be fixed and the fixes will be included in the next update.
I've also uploaded a hot fix (recompiled of Alternet.Parsers.Advanced assembly with these fixes) here.
https://www.alternetsoft.com/forum/AlterNET_10272020.zip
Please let me know if you see any issues with it.
Regards,
Andrew
Hi Andrew,
I can confirm that the reported bugs are fixed in the new Dlls.
Thank you very much
Karol