ILSpy Plugin corrections/enhancements
ILSpy Plugin corrections/enhancements
Hi,
I open a new discussion here that is related to my ILSpy plugin.
If you find an issue in the generated code, please reply here with a sample.
Thanks,
Fab
I open a new discussion here that is related to my ILSpy plugin.
If you find an issue in the generated code, please reply here with a sample.
Thanks,
Fab
XSharp Development Team
fabrice(at)xsharp.eu
fabrice(at)xsharp.eu
ILSpy Plugin corrections/enhancements
Hi Fabrice,
if I translate the following C# Code with your plugin
it says (ignore the "e" we already talked about)
When I compile the X# Code I get the error "error XS1558: 'Functions' does not have a suitable static 'Start' function". Do I always need a start function in X# or why is this start Class/Method not accepted?
if I translate the following C# Code with your plugin
Code: Select all
public class Program
{
static void Main()
{
System.Console.WriteLine("Hello XIDE from c#!");
}
}
Code: Select all
PUBLIC CLASS Program
PRIVATE STATIC METHOD Main() AS VOID
Console.WriteLine("e""Hello XIDE from c#!")
END CLASS
ILSpy Plugin corrections/enhancements
Franz,
X# has chosen to use the Start function instead of the Main method as entry point.
If you change the code to
then you can tell the compiler to use the Program class for the entry point.
In Visual Studio this can be done on the Application page of the Project properties: This sets the compiler option -main: https://www.xsharp.eu/help/opt-main.html
Robert
X# has chosen to use the Start function instead of the Main method as entry point.
If you change the code to
Code: Select all
public class Program
private static method Start() as void
Console.WriteLine("e""Hello XIDE from c#!")
end class
In Visual Studio this can be done on the Application page of the Project properties: This sets the compiler option -main: https://www.xsharp.eu/help/opt-main.html
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
ILSpy Plugin corrections/enhancements
C#
Translation
a little bit complicated and readerName missing in FOREACH, why not directly using array readerNames instead of @@array?
Code: Select all
foreach (var readerName in readerNames) {
...
}
Code: Select all
LOCAL @@array AS STRING[]
@@array := readerNames
FOREACH AS STRING IN @@array
NEXT
ILSpy Plugin corrections/enhancements
Hi Robert,
thank you for info, I changed the code and putted the switch "-main:Program" to Properties/Compiler/Additional Switches in XIDE and it compiled without error.
thank you for info, I changed the code and putted the switch "-main:Program" to Properties/Compiler/Additional Switches in XIDE and it compiled without error.
ILSpy Plugin corrections/enhancements
C#
Translation to X#
Else is lost, what means "continueendif"?
If I do if ... else outside of foreach it translates ok.
You also see the @@array translation of the former noted posting.
Code: Select all
using System;
public class Program
{
static void Main()
{
int[] arr = {1,2,3};
foreach (var val in arr) {
int i = 1;
if (i == 1) {
Console.WriteLine("if");
} else {
Console.WriteLine("else");
Console.WriteLine("else");
}
}
}
}
Code: Select all
using System
public class Program
private static method Main() as void
local arr as Long[]
local @@array as Long[]
local i as Long
//
arr := <Long>;
{1,;
2,;
3;
}
@@array := arr
foreach as Long in @@array
i := 1
if i == 1
Console.WriteLine("e""if")
continueendif
Console.WriteLine("e""else")
Console.WriteLine("e""else")
next
end class
If I do if ... else outside of foreach it translates ok.
You also see the @@array translation of the former noted posting.
ILSpy Plugin corrections/enhancements
Code: Select all
LOCAL @@array AS STRING[]
@@array := readerNames
FOREACH AS STRING IN @@array
NEXT
I could try to handle it, catching all FOREACH and rebuilding/guessing what was the original code.
XSharp Development Team
fabrice(at)xsharp.eu
fabrice(at)xsharp.eu
ILSpy Plugin corrections/enhancements
The "continueendif" is a Plugin error, we are missing a newline between continue and endif; and continue is a C# keyword that translate to a LOOP in X#, that will jump back to the nearest FOR/FOREACH/WHILE/... so there, no need for the ELSE clause as in the IF we are jumping back on top.lagraf wrote: Else is lost, what means "continueendif"?
XSharp Development Team
fabrice(at)xsharp.eu
fabrice(at)xsharp.eu
ILSpy Plugin corrections/enhancements
Fabrice,
1) FOREACH
The @@array is waste but not the problem, foreach has lost readerName where each @@array entry is shown, something like
2) CONTINUEENDIF
if ... else ... endif is not the same like if ... loop ... endif when statements behind the endif, so I testet this and it translates right!
1) FOREACH
Code: Select all
LOCAL @@array AS STRING[]
@@array := readerNames
FOREACH AS STRING IN @@array
NEXT
Code: Select all
FOREACH readerName AS STRING IN @@array
if ... else ... endif is not the same like if ... loop ... endif when statements behind the endif, so I testet this and it translates right!
Code: Select all
foreach as Long in @@array
i := 1
if i == 1
Console.WriteLine("e""if")
else
Console.WriteLine("e""else")
Console.WriteLine("e""else")
endif
Console.WriteLine("ever")
next
Code: Select all
@@array := arr
foreach as Long in @@array
i := 1
if i == 1
Console.WriteLine("e""if")
else
Console.WriteLine("e""else")
Console.WriteLine("e""else")
endif
Console.WriteLine("e""ever")
next
ILSpy Plugin corrections/enhancements
Hi Franz,
I have updated the ILSpy plugin :
The LOOP keyword is now generated instead of "continue"
The variable declaration in FOREACH has been corrected
Same for the "e"scaped String.
Go to the github page : https://github.com/X-Sharp/ILSpy-Plugin
On the right, you can get the latest ILSpy plugin, dated today 2022/04/21
I have also included a version for the latest V7.2.1 version of ILSpy.
Regards,
Fab
I have updated the ILSpy plugin :
The LOOP keyword is now generated instead of "continue"
The variable declaration in FOREACH has been corrected
Same for the "e"scaped String.
Go to the github page : https://github.com/X-Sharp/ILSpy-Plugin
On the right, you can get the latest ILSpy plugin, dated today 2022/04/21
I have also included a version for the latest V7.2.1 version of ILSpy.
Regards,
Fab
XSharp Development Team
fabrice(at)xsharp.eu
fabrice(at)xsharp.eu